mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update American Spectator
This commit is contained in:
parent
e3b1de1131
commit
cae14a92b9
@ -5,44 +5,45 @@ spectator.org
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from css_selectors import Select
|
||||||
|
|
||||||
class TheAmericanSpectator(BasicNewsRecipe):
|
class TheAmericanSpectator(BasicNewsRecipe):
|
||||||
title = 'The American Spectator'
|
title = 'The American Spectator'
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Kovid Goyal'
|
||||||
description = 'News from USA'
|
description = 'News from USA'
|
||||||
category = 'news, politics, USA, world'
|
|
||||||
publisher = 'The American Spectator'
|
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
language = 'en'
|
language = 'en'
|
||||||
INDEX = 'http://spectator.org'
|
|
||||||
auto_cleanup = True
|
auto_cleanup = True
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
|
|
||||||
conversion_options = {
|
def parse_index(self):
|
||||||
'comments' : description
|
root = self.index_to_soup('http://spectator.org/issues/current', as_tree=True)
|
||||||
,'tags' : category
|
select = Select(root)
|
||||||
,'language' : language
|
main = tuple(select('div#block-system-main'))[0]
|
||||||
,'publisher' : publisher
|
feeds = []
|
||||||
}
|
for div in select('div.item-list', main):
|
||||||
|
for h3 in div.xpath('./h3'):
|
||||||
feeds = [ (u'Articles', u'http://feeds.feedburner.com/amspecarticles')]
|
section_title = self.tag_to_string(h3)
|
||||||
|
self.log('\n' + section_title)
|
||||||
def get_cover_url(self):
|
break
|
||||||
cover_url = None
|
else:
|
||||||
soup = self.index_to_soup(self.INDEX)
|
continue
|
||||||
link_item = soup.find('a',attrs={'class':'cover'})
|
articles = []
|
||||||
if link_item:
|
for li in div.xpath('descendant::li'):
|
||||||
soup2 = self.index_to_soup(link_item['href'])
|
for x in select('div.views-field-title', li):
|
||||||
link_item2 = soup2.find('div',attrs={'class':'post inner issues'})
|
title = self.tag_to_string(x)
|
||||||
cover_url = self.INDEX + link_item2.img['src']
|
break
|
||||||
return cover_url
|
else:
|
||||||
|
raise ValueError('No article title found')
|
||||||
def print_version(self, url):
|
url = 'http://spectator.org' + li.xpath('./a/@href')[0]
|
||||||
return url + '/print'
|
desc = ''
|
||||||
|
for x in select('div.views-field-field-short-summary', li):
|
||||||
def get_article_url(self, article):
|
desc = self.tag_to_string(x)
|
||||||
return article.get('guid', None)
|
break
|
||||||
|
articles.append({'title':title, 'url':url, 'description':desc})
|
||||||
|
self.log('\t', title, 'at', url)
|
||||||
|
feeds.append((section_title, articles))
|
||||||
|
return feeds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user