13 lines
373 B
Python
13 lines
373 B
Python
import urllib.request
|
|
from szurubooru import errors
|
|
|
|
|
|
def download(url):
|
|
assert url
|
|
request = urllib.request.Request(url)
|
|
request.add_header('Referer', url)
|
|
try:
|
|
with urllib.request.urlopen(request) as handle:
|
|
return handle.read()
|
|
except Exception as ex:
|
|
raise errors.ProcessingError('Error downloading %s (%s)' % (url, ex))
|