Because of a lot of use of a Web site Urlopen operation, so it will be identified as an attack by the site. Downloads are sometimes no longer allowed. led to Urlopen (), Request.read () had been stuck there. Errno10054 will be thrown at the end.
This error is connection reset Bypeer. The legendary remote host has reset this connection. The reason may be that the socket timeout is too long, or it may be after the request =urllib.request.urlopen (URL), there is no request.close () operation, or there may be no sleep for a few seconds, causing the site to assume that this behavior is an attack.
Specific solutions such as the following code:
Import socket
Import time
Timeout = 20
Socket.setdefaulttimeout (timeout) #这里对整个socket层设置超时时间. If you use the socket again in subsequent files, you do not have to set
Sleep_download_time = 10
Time.sleep (sleep_download_time) #这里时间自己设定
Request = Urllib.request.urlopen (URL) #这里是要读取内容的url
Content = Request.read () #读取, it is common to report anomalies here
Request.close () #记得要关闭