I am trying to scrape a webpage. The page has a select with many options in it. ON selecting one option, the page reloads with a table corresponding to that option. I want to scrape that table. However, the URL stays the same. The only change happens in the form data which on inspection has the value of option selected and a csrf_token. How do I replicate the behaviour in python?
My code:
client = requests.session() url = "https://recruitment.advarisk.com/tests/scraping" client.get(url) csrftoken = client.cookies['csrftoken'] return csrftoken
Bad Request. CSRF token missing or incorrect. I got the csrf value from xpath. But when I post it in data parameter it gives that error.