+ def search(self, expr):
+ 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]
+
+ def byid(self, id):
+ url = self.base + ("manga/%s/" % id)
+ page = soupify(htcache.fetch(url))
+ if page.find("div", id="title") is None:
+ # Assume we got the search page
+ raise KeyError(id)
+ name = page.find("div", id="series_info").find("div", attrs={"class": "cover"}).img["alt"]
+ return manga(self, id, name, url)
+