Mangafox: access page in constant time

Doesn't click through every page to obtain the next. It doesn't change
anything right now but will be better when comix is usable with weboob
This commit is contained in:
Noé Rubinstein 2011-08-22 23:28:42 +02:00 committed by Romain Bignon
commit ae782c02db

View file

@ -40,11 +40,8 @@ class DisplayPage(BasePage):
gallery=gallery, gallery=gallery,
url=src) url=src)
def next_page_url(self): def page_list(self):
return self.document.xpath("//a[img[@id='image']]/attribute::href")[0] return self.document.xpath("//select[@onchange='change_page(this)']/option/attribute::value")
def is_last_page(self):
return len(self.document.xpath("//a[img[@id='image']][@href='javascript:void(0);']"))
class MangafoxBrowser(BaseBrowser): class MangafoxBrowser(BaseBrowser):
PAGES = { r'http://.+\.mangafox.\w+/manga/[^/]+/[^/]+/[^/]+/.+\.html': DisplayPage } PAGES = { r'http://.+\.mangafox.\w+/manga/[^/]+/[^/]+/[^/]+/.+\.html': DisplayPage }
@ -53,9 +50,10 @@ class MangafoxBrowser(BaseBrowser):
self.location(gallery.url) self.location(gallery.url)
assert self.is_on_page(DisplayPage) assert self.is_on_page(DisplayPage)
while not self.page.is_last_page(): for p in self.page.page_list():
self.location('%s.html' % p)
assert self.is_on_page(DisplayPage)
yield self.page.get_page(gallery) yield self.page.get_page(gallery)
self.location(self.page.next_page_url())
def fill_image(self, image, fields): def fill_image(self, image, fields):
if 'data' in fields: if 'data' in fields: