Directly from the python requests examples is this snippet:
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.get("http://httpbin.org/get", params=payload)
print r.url
u'http://httpbin.org/get?key2=value2&key1=value1'
But when I try to pull data from a website (using requests 0.13.0):
payload = {'one' : 'one', 'two' : 'two' }
r = requests.get("http://[ip_removed]/clubs/pairs_results/personal.php", params=payload)
print r.url
http://[ip_removed]/clubs/pairs_results/
That’s not correctly encoded at all. Ideas?
EDIT:
Looks like the site issues a 302 redirect. How do I deal with that to get the same html that my browser will see.
The site simply does a
HTTP 302-redirect here whichrequestsfollows, so you’ll end up on a different url than originally requested. That’s not error but the expected behaviour.If you don’t want that, you can add the
allow_redirects=Falsekeyword argument when sending the request.And by the way: a google search with
inurl:...quickly reveals which site you’re talking about here, even if you remove the ip…