Wednesday, 15 September 2010

Python requests + proxy + 302 redirect, why incorrect request? -


I am using Python requests, and I request a proxy but the site, I 302 redirect, and request Does not work properly It appears that the request sends without proxy and the site gets to know my actual IP.

Pyro code: try: session = session () request = request (', url, headers = headers) prepped = session.prepare_request (requested) resp = Session.send (prepped, proxies = proxy, timeout = 8) session.cookies.clear () print (resp.status_code) except print (resp.history) requests. Exempts.Timeout: Print ("Expiration error ... :(" + "\ n") Exclude requests. Exception. Connection Array: Print ("Connection error ... :(" + "\ n") Except requests .exceptions.HTTP Error: Print ("HTTPError ... :(" + "\ n")

History of reaction

  & lt; response [302] & gt; Basically I need to send a request from another IP and every time with new cookies as new user and so on. But with this code I do not manage to do this Anybody can help me with this and say what is the problem?   

r = request.head (url, allow_redirects = true) print (r.url)


No comments:

Post a Comment