How to write the query?

0 like 0 dislike
3 views
There is a certain website which I need to send a request using the requests library.
How to pass these Heders
GET https://mysite.com/5?embed=1 HTTP/1.1 Host: site.com Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Referer: https://mysite.com Accept-Encoding: gzip, deflate, br Accept-Language: ru-ru,ru;q=0.9,en-US;q=0.8,en;q=0.7 Cookie: _ga=GA1.2.1169963389.1523803584; stel_web_auth=https%3A%2F%2Fweb.telegram.org%2F; stel_ssid=31dffdd3cd3dca265d_2963das1217952533; _gid=GA1.2.1199944186.1524831182


There is such code:
import requests from fake_useragent import UserAgent url = 'https://юрлсайта.ком' r = requests.get(url, headers={'User-Agent': UserAgent().chrome}) print(r.text)
by | 3 views

1 Answer

0 like 0 dislike
import requests url = "https://mysite.com/5" querystring = {"embed":"1%20HTTP/1.1"} headers = { 'Host': "t.me" 'Connection': "keep-alive", 'Upgrade-Insecure-Requests': "1", 'User-Agent': "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36", 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", 'Referer': "https://mysite.com", 'Accept-Encoding': "gzip, deflate, br", 'Accept-Language': "EN-us,EN;q=0.9,en-US;q=0.8,en;q=0.7", 'Cookie': "_ga=GA1.2.1169963389.1523803584; stel_web_auth=https%3A%2F%2Fweb.telegram.org%2F; stel_ssid=31dffdd3cd3dca265d_2963das1217952533; _gid=GA1.2.1199944186.1524831182", 'Cache-Control': "no-cache", 'Postman-Token': "930f1009-7e5f-436e-9b5f-da372e57ac8c" } response = requests.request("GET", url, headers=headers, params=querystring) print(response.text)

There is such a thing as a Postman , you can test the queries. one of the chips - code generation on different footing, including Python requests. do not suggest direct fiercely from there to take it, but to understand how and what can help.
by
110,608 questions
257,186 answers
0 comments
33,863 users