I'm having trouble understanding requests. Let's say I have this request:
POST /user/follow HTTP/1.1
Host: www.website.com
User-Agent: some user agent
Accept: application/json, text/plain, */*
Accept-Language: pl,en-US;q=0.7,en;q=0.3
Referer: https://www.website.com/users/12345/profile
Content-Type: application/json;charset=utf-8
X-CSRF-TOKEN: Ab1/2cde3fGH
Content-Length: 27
Cookie: some-cookie=;
DNT: 1
Connection: close
{"targetUser":"12345"}
How am I supposed to use this information to send a valid request using python? What I found is not really helpful. I need someone to show me an example with the data I gave you.
I would do something like this.
import requests
headers = {
"User-Agent": "some user agent",
"Content-Length": 27
# you get the point
}
data = {
"targetUser" : "12345"
}
url = "www.website.com/user/follow"
r = requests.post(url, headers=headers,data=data)
Yes, you would use cookies to log in. Cookies are a part of the headers.