Created
September 5, 2022 04:25
-
-
Save victormurcia/fde61cce600282690e30b90efd4f5e35 to your computer and use it in GitHub Desktop.
download a file from a URL, returns content of downloaded file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # download a file from a URL, returns content of downloaded file | |
| def download_url(urlpath): | |
| try: | |
| # open a connection to the server | |
| with urlopen(urlpath, timeout=3) as connection: | |
| # read the contents of the url as bytes and return it | |
| return connection.read() | |
| except: | |
| return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment