文章詳情頁
網(wǎng)頁爬蟲 - python urlopen 報錯 timeout: timed out
瀏覽:72日期:2022-06-30 17:47:53
問題描述
今天腳本總報timeout的錯誤,timeout的異常處理是什么啊?下面的try except沒用
try: url_open = urllib.request.urlopen(url)except urllib.error.HTTPError: print(’HTTPError’) continueexcept urllib.error.URLError: print(’URLError’) continue
就是返回
File 'F:Program Files (x86)Anaconda3libhttpclient.py', line 612, in _safe_read chunk = self.fp.read(min(amt, MAXAMOUNT)) File 'F:Program Files (x86)Anaconda3libsocket.py', line 586, in readinto return self._sock.recv_into(b) timeout: timed out
把except寫成
except Exception:
也沒用
問題解答
回答1:試試requests.get(url)
相關(guān)文章:
1. python文檔怎么查看?2. python - pycharm 自動刪除行尾空格3. 安全性測試 - nodejs中如何防m(xù)ySQL注入4. python - pandas按照列A和列B分組,將列C求平均數(shù),怎樣才能生成一個列A,B,C的dataframe5. python - Pycharm的Debug用不了6. html - eclipse 標簽錯誤7. python 利用subprocess庫調(diào)用mplayer時發(fā)生錯誤8. 請問PHPstudy中的數(shù)據(jù)庫如何創(chuàng)建索引9. datetime - Python如何獲取當前時間10. javascript - 有適合開發(fā)手機端Html5網(wǎng)頁小游戲的前端框架嗎?
排行榜

熱門標簽