mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
24 lines
503 B
Python
24 lines
503 B
Python
import os
|
|
import sys
|
|
import urllib.parse
|
|
import urllib.request
|
|
|
|
|
|
def fetch(url):
|
|
name = urllib.parse.urlsplit(url)[2].split("/")[-1]
|
|
|
|
if not os.path.exists(name):
|
|
print("Fetching", url)
|
|
try:
|
|
r = urllib.request.urlopen(url)
|
|
except urllib.error.URLError:
|
|
r = urllib.request.urlopen(url)
|
|
content = r.read()
|
|
with open(name, "wb") as fd:
|
|
fd.write(content)
|
|
return name
|
|
|
|
|
|
if __name__ == "__main__":
|
|
fetch(sys.argv[1])
|