urllib.error.ContentTooShortError: <urlopen error retrieval incomplete

419 Views Asked by At

when I am using undetected_chromedriver to do some test with my own website, the process always shows error:

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

this is the code look like:

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()

it seems everytime start the undetected_chromedriver, it will download the driver or google chrome, is it possible to cache the file or download continuely? if first time download failed, the next time start from previous newest location. what should I do to fixed this issue?

0

There are 0 best solutions below