2012-11-28 17:15:12 +00:00
|
|
|
#!/usr/bin/env python
|
2016-04-11 22:36:33 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-04-12 22:52:16 +00:00
|
|
|
# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs
|
|
|
|
# Copyright (C) 2012-2014 Bastian Kleineidam
|
|
|
|
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
2012-11-28 17:15:12 +00:00
|
|
|
"""
|
2016-04-12 22:52:16 +00:00
|
|
|
Script to get a list of gocomics and save the info in a JSON file for further
|
|
|
|
processing.
|
2012-11-28 17:15:12 +00:00
|
|
|
"""
|
2016-04-11 22:36:33 +00:00
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
from scriptutil import ComicListUpdater
|
|
|
|
|
|
|
|
|
|
|
|
class GoComicsUpdater(ComicListUpdater):
|
|
|
|
# names of comics to exclude
|
|
|
|
excluded_comics = [
|
|
|
|
# "coming soon"
|
2016-04-17 16:40:09 +00:00
|
|
|
"AngryProgrammer",
|
2016-04-14 20:22:37 +00:00
|
|
|
"Guinness",
|
|
|
|
"Jabberwoncky",
|
2016-04-17 16:40:09 +00:00
|
|
|
"Pi",
|
|
|
|
"RandysRationale",
|
2016-04-14 20:22:37 +00:00
|
|
|
"SignsOfOurTimes",
|
|
|
|
"TheGagwriter",
|
|
|
|
"Yaoyao",
|
|
|
|
|
|
|
|
# duplicate
|
2016-04-17 16:40:09 +00:00
|
|
|
"Dilbert",
|
2016-04-14 20:22:37 +00:00
|
|
|
"SaturdayMorningBreakfastCereal",
|
2016-04-17 16:40:09 +00:00
|
|
|
|
|
|
|
# not available
|
|
|
|
"BuffaloChips",
|
|
|
|
"Crawdiddy",
|
2016-04-14 20:22:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def handle_url(self, url):
|
|
|
|
"""Parse one search result page."""
|
2016-04-14 22:26:14 +00:00
|
|
|
data = self.get_url(url, expand=False)
|
2016-04-14 20:22:37 +00:00
|
|
|
|
|
|
|
for comiclink in data.cssselect('a.alpha_list'):
|
|
|
|
link = comiclink.attrib['href']
|
|
|
|
name = comiclink.text
|
|
|
|
self.add_comic(name, link)
|
|
|
|
|
|
|
|
def collect_results(self):
|
|
|
|
"""Parse all listing pages."""
|
|
|
|
self.handle_url('http://www.gocomics.com/features')
|
|
|
|
self.handle_url('http://www.gocomics.com/explore/espanol')
|
|
|
|
self.handle_url('http://www.gocomics.com/explore/editorial_list')
|
|
|
|
self.handle_url('http://www.gocomics.com/explore/sherpa_list')
|
|
|
|
|
|
|
|
def get_classdef(self, name, url):
|
|
|
|
return u"class GC%s(_GoComics%s):\n path = %r" % (
|
|
|
|
name, 'Es' if 'espanol/' in url else '', url[1:])
|
2012-11-28 17:15:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-04-14 20:22:37 +00:00
|
|
|
GoComicsUpdater(__file__).run()
|