Python: requests.exceptions.ConnectionError. Max retries exceeded with url

后端 未结 3 1390
情歌与酒
情歌与酒 2020-12-25 11:11

This is the script:

import requests
import json
import urlparse
from requests.adapters import HTTPAdapter

s = requests.Session()
s.mount(\'http://\', HTTPAd         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-25 11:43

    Looking at stack trace you've provided your error is caused by httplib.BadStatusLine exception, which, according to docs, is:

    Raised if a server responds with a HTTP status code that we don’t understand.

    In other words something that is returned (if returned at all) by proxy server cannot be parsed by httplib that does actual request.

    From my experience with (writing) http proxies I can say that some implementations may not follow specs too strictly (rfc specs on http aren't easy reading actually) or use hacks to fix old browsers that have flaws in their implementation.

    So, answering this:

    Could it be a bad proxy?

    ... I'd say - that this is possible. The only real way to be sure is to see what is returned by proxy server.

    Try to debug it with debugger or grab packet sniffer (something like Wireshark or Network Monitor) to analyze what happens in the network. Having info about what exactly is returned by proxy server should give you a key to solve this issue.

提交回复
热议问题