2
我正在使用請求庫從某處獲取大量網頁。他是相關代碼:Python請求掛/凍結
response = requests.Session()
retries = Retry(total=5, backoff_factor=.1)
response.mount('http://', HTTPAdapter(max_retries=retries))
response = response.get(url)
過了一會兒,它只是掛起/凍結(從來沒有在同一個網頁),而得到的頁面。當我中斷它時,回溯如下:
File "/Users/Student/Hockey/Scrape/html_pbp.py", line 21, in get_pbp
response = r.read().decode('utf-8')
File "/anaconda/lib/python3.6/http/client.py", line 456, in read
return self._readall_chunked()
File "/anaconda/lib/python3.6/http/client.py", line 566, in _readall_chunked
value.append(self._safe_read(chunk_left))
File "/anaconda/lib/python3.6/http/client.py", line 612, in _safe_read
chunk = self.fp.read(min(amt, MAXAMOUNT))
File "/anaconda/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
有沒有人知道什麼可能導致它?或者(更重要的是)有沒有人知道一種方法來阻止它,如果它需要超過一定的時間,以便我可以再試一次?