Celery 或 urllib3 将我重定向到 https
Celery or urllib3 is redirecting me to https
我在通过 urllib3 发出请求时遇到问题。所以,我通过代理和 运行 脚本连接 celery。
urllib3 设置:
self.http = urllib3.ProxyManager('http://127.0.0.1:24000')
Urllib3 请求:
page = self.http.request('get', self.start_url, headers=self.headers)
之后我在 celery 日志中看到类似这样的内容:
[2019-11-19 16:13:54,038: INFO/ForkPoolWorker-2] Redirecting http://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/ -> https://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/
如何禁用此重定向?
不是urllib3也不是celery,是远程服务器
$ curl -D- http://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Location: https://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/
Expires: Tue, 19 Nov 2019 16:33:49 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Tue, 19 Nov 2019 16:33:49 GMT
Connection: keep-alive
Server: OLXcdn
X-T: True
如您所见,服务器将您重定向到 HTTPS,因此您无法在客户端禁用它。
我在通过 urllib3 发出请求时遇到问题。所以,我通过代理和 运行 脚本连接 celery。
urllib3 设置:
self.http = urllib3.ProxyManager('http://127.0.0.1:24000')
Urllib3 请求:
page = self.http.request('get', self.start_url, headers=self.headers)
之后我在 celery 日志中看到类似这样的内容:
[2019-11-19 16:13:54,038: INFO/ForkPoolWorker-2] Redirecting http://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/ -> https://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/
如何禁用此重定向?
不是urllib3也不是celery,是远程服务器
$ curl -D- http://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Location: https://www.olx.pl/nieruchomosci/mieszkania/wynajem/wroclaw/
Expires: Tue, 19 Nov 2019 16:33:49 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Tue, 19 Nov 2019 16:33:49 GMT
Connection: keep-alive
Server: OLXcdn
X-T: True
如您所见,服务器将您重定向到 HTTPS,因此您无法在客户端禁用它。