Skip to content

Instantly share code, notes, and snippets.

@VladRez
Last active April 21, 2019 00:04
Show Gist options
  • Save VladRez/9297445e90101d03af081268fc86afc7 to your computer and use it in GitHub Desktop.
Save VladRez/9297445e90101d03af081268fc86afc7 to your computer and use it in GitHub Desktop.
import urllib.request
url = 'https://www.somewebsite.com/somefile'
req = urllib.request.Request(url, method='HEAD')
res = urllib.request.urlopen(req)
filename = res.info().get_filename()
urllib.request.urlretreve(url, f"/target/dir/{filename}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment