P
P
piki_adm2020-07-05 19:22:09
Python
piki_adm, 2020-07-05 19:22:09

How to create a request to the site and return the values?

i need to flip the text. I found the site: https://ciox.ru/text-upside-down. How to send a request there and get an inverted phrase (word)? requests

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-05
@piki_adm

f12->network. We send a request, we look at what went. Through requests we make the same request, then through bs4 we pull out the result

import requests
from bs4 import BeautifulSoup


headers = {'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'content-type': 'application/x-www-form-urlencoded',
            'referer': 'https://ciox.ru/text-upside-down',
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'}

payload = 'usertext=texthere&enter='

s = requests.Session()

s.get('https://ciox.ru/text-upside-down', headers=headers)
r = s.post('https://ciox.ru/text-upside-down', data=payload, headers=headers)


soup = BeautifulSoup(r.text, 'html.parser')
result = soup.find('textarea', {'class': 'input_c result'})
print(result.text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question