Answer the question
In order to leave comments, you need to log in
How to send a POST request to change data on the site?
I make a post request to the site to enter some data, from the browser I saw that it takes 3 values, filling them in, I get a response from page 419, googling, I suggested that I need to send an xsrf token, but I can’t figure out exactly where. I will be glad for any help.
The code:
import requests
from bs4 import BeautifulSoup as BS
s = requests.Session()
auth_html = s.get("")
auth_bs = BS(auth_html.content, "html.parser")
csrf = auth_bs.select("meta[name=csrf-token]")[0]["content"]
payload = {
"_token": csrf,
"email": "",
"password": ""
}
answ = s.post("", data = payload)
#category_id = int(input("ID: "))
category = {
"categoriesIds[]": 1405,
"marketplaceCategory": 4438,
"_method": "patch"
}
get = s.get("", data = category)
print("Status code: " + str(get.status_code)) # 419
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question