mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Recipe for Utne.com (thanks to Darko Miletic)
This commit is contained in:
parent
abd477fc71
commit
18203fe159
BIN
src/calibre/gui2/images/news/utne.png
Normal file
BIN
src/calibre/gui2/images/news/utne.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 919 B |
@ -18,7 +18,7 @@ recipe_modules = [
|
|||||||
'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times',
|
'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times',
|
||||||
'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas',
|
'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas',
|
||||||
'science_news', 'the_nation', 'lrb', 'harpers_full', 'liberation',
|
'science_news', 'the_nation', 'lrb', 'harpers_full', 'liberation',
|
||||||
'linux_magazine', 'telegraph_uk'
|
'linux_magazine', 'telegraph_uk', 'utne',
|
||||||
]
|
]
|
||||||
|
|
||||||
import re, imp, inspect, time, os
|
import re, imp, inspect, time, os
|
||||||
|
49
src/calibre/web/feeds/recipes/utne.py
Normal file
49
src/calibre/web/feeds/recipes/utne.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
utne.com
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class Utne(BasicNewsRecipe):
|
||||||
|
title = u'Utne reader'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'News'
|
||||||
|
oldest_article = 7
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = False
|
||||||
|
|
||||||
|
cover_url = 'http://www.utne.com/images/template/logo.gif'
|
||||||
|
|
||||||
|
remove_tags = [
|
||||||
|
dict(name='a' , attrs={'id':'ctl00_blankmaster_lnkBanner' })
|
||||||
|
,dict(name='object')
|
||||||
|
]
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
(u'Politics' , u'http://www.utne.com/rss/Politics.xml')
|
||||||
|
,(u'Environment' , u'http://www.utne.com/rss/Environment.xml')
|
||||||
|
,(u'Media' , u'http://www.utne.com/rss/Media.xml')
|
||||||
|
,(u'Great writing', u'http://www.utne.com/rss/Great-Writing.xml')
|
||||||
|
,(u'Science & Technology', u'http://www.utne.com/rss/Science-Technology.xml')
|
||||||
|
,(u'Arts', u'http://www.utne.com/rss/Arts.xml')
|
||||||
|
]
|
||||||
|
|
||||||
|
def print_version(self, url):
|
||||||
|
raw = self.browser.open(url).read()
|
||||||
|
soup = BeautifulSoup(raw.decode('utf8', 'replace'))
|
||||||
|
print_link = soup.find('a', {'id':'ctl00_defaultmaster_Blog_tools1_lnkPrint'})
|
||||||
|
if print_link is None:
|
||||||
|
return url
|
||||||
|
return print_link['href']
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
mtag = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
|
||||||
|
soup.head.insert(0,mtag)
|
||||||
|
del(soup.body['onload'])
|
||||||
|
return soup
|
Loading…
x
Reference in New Issue
Block a user