Dolda2000 GitWeb
/
automanga.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Specify a custom user-agent string for all default requests.
[automanga.git]
/
manga
/
htcache.py
diff --git
a/manga/htcache.py
b/manga/htcache.py
index
45ede5d
..
5f28c00
100644
(file)
--- a/
manga/htcache.py
+++ b/
manga/htcache.py
@@
-11,7
+11,8
@@
class cache(object):
return n.hexdigest()
def miss(self, url):
return n.hexdigest()
def miss(self, url):
- with urllib.request.urlopen(url) as s:
+ req = urllib.request.Request(url, headers={"User-Agent": "automanga/1"})
+ with urllib.request.urlopen(req) as s:
if s.headers.get("content-encoding") == "gzip":
import gzip, io
return gzip.GzipFile(fileobj=io.BytesIO(s.read()), mode="r").read()
if s.headers.get("content-encoding") == "gzip":
import gzip, io
return gzip.GzipFile(fileobj=io.BytesIO(s.read()), mode="r").read()