Reputation: 71
I'm using python requests to parse a web page. The problem I have is that I'm requesting XML for 2 different paths but when I parse the results, they are the same when they should be different:
ca_page = requests.get(../ca/..)
en_page = requests.get(../en/..)
When I access the page in my browser I can see that the values are different but when I send a request, the values are the same. Any ideas why this is happening?
Update:
So turns out requests has the following to prevent redirects
page = requests.get(url, allow_redirects=False)
The problem with this is that I get the correct url, but it no longer loads the correct html tags
Upvotes: 2
Views: 44
Reputation: 3346
maybe you can make request in different sessions and check e.g:
with requests.session() as s1:
ca_page = s1.get(../ca/..)
print ca_page
with requests.session() as s2:
en_page = s2.get(../en/..)
print en_page
If this does not work then check the documentation of the api/url which you are calling.
Upvotes: 1