作者:乃_黄包11_753 | 来源:互联网 | 2023-07-03 17:28
ImusingPythonrequestsandIsendrequeststhroughaproxy.ThesiteImsendingrequeststohas
I'm using Python requests and I send requests through a proxy. The site I'm sending requests to has 302 redirection, and the request doesn't work properly. It seems that the request sends without proxy and the site finds out my real IP.
我正在使用Python请求,我通过代理发送请求。我发送请求的站点有302重定向,请求无法正常工作。似乎请求发送没有代理,网站发现我的真实IP。
Python code:
try:
session = Session()
request = Request('GET', url, headers=headers)
prepped = session.prepare_request(request)
resp = session.send(prepped, proxies=proxy, timeout=8)
session.COOKIEs.clear()
print(resp.status_code)
print(resp.history)
except requests.exceptions.Timeout:
print("Timeout error ... :( " + "\n")
except requests.exceptions.ConnectionError:
print("Connection error ... :( " + "\n")
except requests.exceptions.HTTPError:
print("HTTPError ... :( " + "\n")
Response history
Basically I need to send request from another IP and every time as a new user with new COOKIEs and so on. But with this code I can't manage to do it. Can someone help me with this and say what's the problem?
基本上我需要从另一个IP发送请求,并且每次都作为新用户发送新COOKIE等等。但是使用这段代码我无法做到。有人可以帮助我,并说出问题是什么?
2 个解决方案