- resp = urllib.urlopen(self.base + ("ajax/search.php?term=%s" % urllib.quote(expr)))
- try:
- rc = json.load(resp)
- finally:
- resp.close()
- return [manga(self, id.encode("utf8"), name, self.base + ("manga/%s/" % id.encode("utf8"))) for num, name, id, genres, author in rc]
+ req = urllib.request.Request(self.base + ("ajax/search.php?term=%s" % urllib.parse.quote(expr)),
+ headers={"User-Agent": "automanga/1"})
+ with urllib.request.urlopen(req) as resp:
+ rc = json.loads(resp.read().decode("utf-8"))
+ return [manga(self, id, name, self.base + ("manga/%s/" % id)) for num, name, id, genres, author in rc]