提问人:Dolphin 提问时间:11/16/2023 更新时间:11/16/2023 访问量:23
urllib.error.ContentTooShortError:<urlopen 错误检索不完整
urllib.error.ContentTooShortError: <urlopen error retrieval incomplete
问:
当我使用undetected_chromedriver对我自己的网站进行一些测试时,该过程总是显示错误:
Traceback (most recent call last):
File "/Users/xiaoqiangjiang/Applications/PyCharm Community Edition.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1500, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/xiaoqiangjiang/Applications/PyCharm Community Edition.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/xiaoqiangjiang/source/dolphin/visa/main.py", line 6, in <module>
visa_entry.start_visa()
File "/Users/xiaoqiangjiang/source/dolphin/visa/apps/visa/browser/visa_entry.py", line 16, in start_visa
entry.open_undetect_browser()
File "/Users/xiaoqiangjiang/source/dolphin/visa/apps/visa/browser/visa_entry.py", line 19, in open_undetect_browser
driver = uc.Chrome(
File "/Users/xiaoqiangjiang/source/dolphin/visa/venv/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 258, in __init__
self.patcher.auto()
File "/Users/xiaoqiangjiang/source/dolphin/visa/venv/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 178, in auto
self.unzip_package(self.fetch_package())
File "/Users/xiaoqiangjiang/source/dolphin/visa/venv/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 287, in fetch_package
return urlretrieve(download_url)[0]
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 280, in urlretrieve
raise ContentTooShortError(
urllib.error.ContentTooShortError: <urlopen error retrieval incomplete: got only 9436198 out of 9813136 bytes>
python-BaseException
这是代码的样子:
def open_undetect_browser(self):
driver = uc.Chrome(
headless=False,
use_subprocess=False,
)
try:
driver.get('https://example.com')
wait: WebDriverWait = WebDriverWait(driver, 600)
except Exception as e:
visa_logger.error("start undetect browser facing issue", e)
finally:
driver.quit()
似乎每次启动undetected_chromedriver时,它都会下载驱动程序或Google Chrome,是否可以缓存文件或继续下载?如果第一次下载失败,下次从上一个最新位置开始。我应该怎么做才能解决此问题?
答: 暂无答案
评论