Comments¶
It is suggested that you use the requests module instead of urllib unless you want to have minimal 3rd-party dependencies.
Response.raise_for_statusis a convenient method for raising an exception corresponding to the HTTP status code.
Download Files from the Internet in Python
The shell command curl and wget can be called (using os.system or subprocess.run)
to download files from internet.
You can also download files using Python modules directly of course.