Repair gocomics updater

This commit is contained in:
Tobias Gruetzmacher 2020-04-20 01:03:30 +02:00
parent 131deeaa34
commit 6cfe67536e

View file

@ -2,7 +2,7 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2020 Tobias Gruetzmacher
""" """
Script to get a list of gocomics and save the info in a JSON file for further Script to get a list of gocomics and save the info in a JSON file for further
processing. processing.
@ -18,25 +18,25 @@ class GoComicsUpdater(ComicListUpdater):
'LukeyMcGarrysTLDR', 'LukeyMcGarrysTLDR',
) )
def handle_gocomics(self, url, outercss='a.amu-media-item-link', lang=None): def handle_gocomics(self, url, outercss='a.gc-blended-link', lang=None):
"""Parse one GoComics alphabetic page.""" """Parse one GoComics alphabetic page."""
data = self.get_url(url, expand=False) data = self.get_url(url, expand=False)
for comiclink in data.cssselect(outercss): for comiclink in data.cssselect(outercss):
link = comiclink.attrib['href'] link = comiclink.attrib['href'].split('/')[1]
name = comiclink.cssselect('h4')[0].text name = comiclink.cssselect('h4')[0].text
self.add_comic(name, (link, lang)) self.add_comic(name, (link, lang))
def collect_results(self): def collect_results(self):
"""Parse all listing pages.""" """Parse all listing pages."""
for part in ('a-b', 'c-e', 'f-i', 'j-n', 'o-r', 's-t', 'u-%23'): self.handle_gocomics('http://www.gocomics.com/comics/a-to-z')
self.handle_gocomics('http://www.gocomics.com/comics/a-to-z?page=' + part) self.handle_gocomics('http://www.gocomics.com/comics/espanol', lang='es')
self.handle_gocomics('http://www.gocomics.com/comics/espanol', 'a.gc-card-item', 'es') self.handle_gocomics('http://www.gocomics.com/comics/espanol?page=2', lang='es')
def get_entry(self, name, data): def get_entry(self, name, data):
url, lang = data url, lang = data
langopt = ", '%s'" % lang if lang else '' langopt = ", '%s'" % lang if lang else ''
return u"cls('%s', '%s'%s)," % (name, url[1:], langopt) return u"cls('%s', '%s'%s)," % (name, url, langopt)
if __name__ == '__main__': if __name__ == '__main__':