MMO P&S Anyone know about Python requests? Am I doing this wrong?

LocalSk8r

Well-known member
VIP MEMBER
Joined
May 18, 2016
Messages
119
Is there an error in my approach? I've identified the CSRF token in the initial GET request and supplied it in the subsequent POST request, yet I still encounter a "CSRF token failed" message. I'm employing sessions in my requests.
 
Are you using the same session or starting a new one each time? That could be the issue. Try setting the browser to use the same profile for the next requests.

Edit:

This might work...

Here's the code :
 
Since this is about requests, you need to keep the session active for all your transactions.
import requests

# Create a session to keep requests active
s = requests.Session()

# Send a GET request
response_get = s.get(your_get_url, headers=your_get_headers)

# Send a POST request
response_post = s.post(your_post_url, headers=your_post_headers, data=your_post_data)
 
Are you using the same session or starting a new one each time? That could be the issue. Try setting the browser to use the same profile for the next requests.

Edit:

This might work...

Since this is about requests, you need to keep the session active for all your transactions.
import requests

# Create a session to keep requests active
s = requests.Session()

# Send a GET request
response_get = s.get(your_get_url, headers=your_get_headers)

# Send a POST request
response_post = s.post(your_post_url, headers=your_post_headers, data=your_post_data)

The problem wasn't that—I didn't read carefully. The issue is with the cookies in the requests.
 
Since this is about requests, you need to keep the session active for all your transactions.

import requests

# Create a session to keep requests active
s = requests.Session()

# Send a GET request
response_get = s.get(your_get_url, headers=your_get_headers)

# Send a POST request
response_post = s.post(your_post_url, headers=your_post_headers, data=your_post_data)

Oh, haha, I totally thought he was using Selenium. But yeah, the same idea works for requests too.

The problem wasn't that—I didn't read carefully. The issue is with the cookies in the requests.

By using the same session, you also keep the same cookies. So, the same solution should work for you.
 
Oh, haha, I totally thought he was using Selenium. But yeah, the same idea works for requests too.



By using the same session, you also keep the same cookies. So, the same solution should work for you.

Yeah, but it says the cookies are wrong. I’ll need to figure that out. Thanks anyway!
 
Similar threads Most view View more
Back
Top Bottom