How to know if urllib.urlretrieve succeeds?

后端 未结 8 1946
长情又很酷
长情又很酷 2020-11-30 01:20

urllib.urlretrieve returns silently even if the file doesn\'t exist on the remote http server, it just saves a html page to the named file. For example:

8条回答
  •  广开言路
    2020-11-30 01:36

    You can create a new URLopener (inherit from FancyURLopener) and throw exceptions or handle errors any way you want. Unfortunately, FancyURLopener ignores 404 and other errors. See this question:

    How to catch 404 error in urllib.urlretrieve

提交回复
热议问题