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

后端 未结 3 1389
情歌与酒
情歌与酒 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:39

    Maybe you are overloading the proxy server by sending too much requests in a short period of time, you say that you got the proxy from a popular free proxy website which means that you're not the only one using that server and it's often under heavy load.

    If you add some delay between your requests like this :

    from time import sleep
    
    [...]
    
    data=requests.get(url, proxies=proxy)
    data1=data.content
    print data1
    print {'http': line}
    sleep(1)
    

    (note the sleep(1) which pauses the execution of the code for one second)

    Does it work ?

提交回复
热议问题