gallery.accords-library.com/server/szurubooru/func/net.py

14 lines
373 B
Python
Raw Normal View History

2016-05-05 11:23:15 +00:00
import urllib.request
2016-09-25 12:52:47 +00:00
from szurubooru import errors
2016-05-05 11:23:15 +00:00
2016-05-05 11:23:15 +00:00
def download(url):
2016-08-14 08:45:00 +00:00
assert url
2016-05-05 11:23:15 +00:00
request = urllib.request.Request(url)
request.add_header('Referer', url)
2016-09-25 12:52:47 +00:00
try:
with urllib.request.urlopen(request) as handle:
return handle.read()
2016-09-26 20:51:00 +00:00
except Exception as ex:
raise errors.ProcessingError('Error downloading %s (%s)' % (url, ex))