Use new features to make modules simpler.

This commit is contained in:
Tobias Gruetzmacher 2016-04-13 23:28:43 +02:00
parent b266e28ae1
commit db87ed95e7
3 changed files with 13 additions and 15 deletions

View file

@ -6,22 +6,22 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from ..scraper import _ParserScraper from ..scraper import _ParserScraper
from ..helpers import indirectStarter
class _Creators(_ParserScraper): class _Creators(_ParserScraper):
url = 'https://www.creators.com/features/'
imageSearch = '//a[contains(@class,"fancybox")]/img' imageSearch = '//a[contains(@class,"fancybox")]/img'
prevSearch = '//a[@id="nav_prev"]' prevSearch = '//a[@id="nav_prev"]'
latestSearch = '//div[contains(@class,"caption")]/a' latestSearch = '//div[contains(@class,"caption")]/a'
starter = indirectStarter
@property @property
def name(self): def name(self):
return 'Creators/' + super(_Creators, self).name return 'Creators/' + super(_Creators, self).name
def starter(self): @property
start = self.url + self.path def url(self):
data = self.getPage(start) return 'https://www.creators.com/features/' + self.path
return self.fetchUrl(start, data, self.latestSearch)
class _CreatorsEs(_Creators): class _CreatorsEs(_Creators):

View file

@ -6,6 +6,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from ..scraper import _ParserScraper from ..scraper import _ParserScraper
from ..helpers import bounceStarter
class _GoComics(_ParserScraper): class _GoComics(_ParserScraper):
@ -14,18 +15,16 @@ class _GoComics(_ParserScraper):
'//p[@class="feature_item"]/img[@class="strip"]') '//p[@class="feature_item"]/img[@class="strip"]')
prevSearch = '//ul[@class="feature-nav"]//a[@class="prev"]' prevSearch = '//ul[@class="feature-nav"]//a[@class="prev"]'
nextSearch = '//ul[@class="feature-nav"]//a[@class="next"]' nextSearch = '//ul[@class="feature-nav"]//a[@class="next"]'
starter = bounceStarter
help = 'Index format: yyyy/mm/dd' help = 'Index format: yyyy/mm/dd'
@property @property
def name(self): def name(self):
return 'GoComics/' + super(_GoComics, self).name[2:] return 'GoComics/' + super(_GoComics, self).name[2:]
def starter(self): @property
url1 = self.url + self.path def url(self):
data = self.getPage(url1) return 'http://www.gocomics.com/' + self.path
url2 = self.fetchUrl(url1, data, self.prevSearch)
data = self.getPage(url2)
return self.fetchUrl(url2, data, self.nextSearch)
@classmethod @classmethod
def namer(cls, image_url, page_url): def namer(cls, image_url, page_url):

View file

@ -7,12 +7,12 @@ from ..scraper import _ParserScraper
class _NuklearPower(_ParserScraper): class _NuklearPower(_ParserScraper):
url = 'http://www.nuklearpower.com/'
prevSearch = '//a[@rel="prev"]' prevSearch = '//a[@rel="prev"]'
imageSearch = '//div[@id="comic"]/img' imageSearch = '//div[@id="comic"]/img'
def starter(self): @property
return self.url + self.path + '/' def url(self):
return 'http://www.nuklearpower.com/' + self.path + '/'
@property @property
def name(self): def name(self):
@ -26,7 +26,6 @@ class NP8BitTheater(_NuklearPower):
class NPAtomicRobo(_NuklearPower): class NPAtomicRobo(_NuklearPower):
url = 'http://www.atomic-robo.com/' url = 'http://www.atomic-robo.com/'
imageSearch = '//img[@id="cc-comic"]' imageSearch = '//img[@id="cc-comic"]'
path = 'atomicrobo'
class NPHowIKilledYourMaster(_NuklearPower): class NPHowIKilledYourMaster(_NuklearPower):