M
M
Mikhail Muntyan2022-02-24 22:14:31
Python
Mikhail Muntyan, 2022-02-24 22:14:31

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

6217d9083dd6b522904827.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-02-24
@SoreMix

How to send a POST request

Send GET in code. Or what request are you talking about? There is nothing to do without a link to the site

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question