dosage/scripts/arcamax.py

45 lines
1.2 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
2016-10-28 22:21:41 +00:00
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
2016-04-12 22:52:16 +00:00
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2021 Tobias Gruetzmacher
2013-01-23 18:34:11 +00:00
"""
2016-04-12 22:52:16 +00:00
Script to get arcamax comics and save the info in a JSON file for further
processing.
2013-01-23 18:34:11 +00:00
"""
2016-04-12 22:52:16 +00:00
from scriptutil import ComicListUpdater
2016-04-12 22:52:16 +00:00
class ArcamaxUpdater(ComicListUpdater):
dup_templates = ("Creators/%s", "DrunkDuck/%s", "GoComics/%s",
"KeenSpot/%s", "ComicGenesis/%s")
2013-01-23 18:34:11 +00:00
# names of comics to exclude
excluded_comics = (
# better source available
"Dilbert",
"HagarTheHorrible",
)
2013-01-23 18:34:11 +00:00
def handle_url(self, url):
"""Parse one search result page."""
data = self.get_url(url)
2013-01-23 18:34:11 +00:00
for comiclink in data.cssselect('a.comic-icon'):
path = comiclink.attrib['href']
name = comiclink.attrib['title']
2013-01-23 18:34:11 +00:00
self.add_comic(name, path.rsplit('/', 2)[1])
def collect_results(self):
"""Parse all search result pages."""
self.handle_url('http://www.arcamax.com/comics')
2013-01-23 18:34:11 +00:00
2016-05-22 20:55:06 +00:00
def get_entry(self, name, entry):
return u"cls('%s', '%s')," % (name, entry)
2013-01-23 18:34:11 +00:00
if __name__ == '__main__':
ArcamaxUpdater(__file__).run()