[Python] Trouble with downloading a zip file with incomplete read

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I'm having trouble downloading this zip file from the URL: https://www.dgii.gov.do/app/WebApps/Consultas/RNC/DGII_RNC.zip with python code.

    I tried many things but every time I try to download the zip the file seems to be corrupted and doesn't have the whole content.

    The only way I can download it is by manually entering the URL in a web browser.

    One of the errors I ran into consistently:


    requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(8388608 bytes read, 12299532 more expected)', IncompleteRead(8388608 bytes read, 12299532 more expected))
    ​

    import wget

    wget.download('https://www.dgii.gov.do/app/WebApps/Consultas/RNC/DGII_RNC.zip')

    Traceback (most recent call last):
    File "/home/marko-anchev/PycharmProjects/pythonProject1/main.py", line 3, in <module>
    wget.download('https://www.dgii.gov.do/app/WebApps/Consultas/RNC/DGII_RNC.zip')
    File "/home/marko-anchev/PycharmProjects/pythonProject1/.venv/lib/python3.12/site-packages/wget.py", line 526, in download
    (tmpfile, headers) = ulib.urlretrieve(binurl, tmpfile, callback)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/urllib/request.py", line 276, in urlretrieve
    raise ContentTooShortError(
    urllib.error.ContentTooShortError: <urlopen error retrieval incomplete: got only 8388608 out of 20696791 bytes>


    Thank you in advance.

    Continue reading...

Compartilhe esta Página