| 1 |
#!/usr/bin/env python |
| 2 |
__license__ = 'GPL v3' |
| 3 |
__copyright__ = '2008, Kovid Goyal [email protected]' |
| 4 |
__docformat__ = 'restructuredtext en' |
| 5 |
|
| 6 |
import re |
| 7 |
|
| 8 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 9 |
|
| 10 |
|
| 11 |
class UnitedPressInternational(BasicNewsRecipe): |
| 12 |
title = 'United Press International' |
| 13 |
max_articles_per_feed = 15 |
| 14 |
html2lrf_options = ['--override-css= "H1 {font-family: Arial; font-weight: bold; color: #000000; size: 10pt;}"'] |
| 15 |
language = 'en' |
| 16 |
|
| 17 |
preprocess_regexps = [ |
| 18 |
(re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) |
| 19 |
for i in [ |
| 20 |
(r'<HEAD>.*?</HEAD>', lambda match: '<HEAD></HEAD>'), |
| 21 |
(r'<div id="apple-rss-sidebar-background">.*?<!-- start Entries -->', lambda match: ''), |
| 22 |
(r'<!-- end apple-rss-content-area -->.*?</body>', lambda match: '</body>'), |
| 23 |
(r'<script.*?>.*?</script>', lambda match: ''), |
| 24 |
(r'<body onload=.*?>.*?<a href="http://www.upi.com">', lambda match: '<body style="font: 8pt arial;">'), |
| 25 |
(r'<script src="http://www.g.*?>.*?</body>', lambda match: ''), |
| 26 |
(r'<span style="font: 16pt arial', lambda match: '<span style="font: 12pt arial'), |
| 27 |
] |
| 28 |
] |
| 29 |
|
| 30 |
def get_feeds(self): |
| 31 |
return [ |
| 32 |
('Top Stories', 'http://www.upi.com/rss/NewsTrack/Top_News/'), |
| 33 |
('Science', 'http://www.upi.com/rss/NewsTrack/Science/'), |
| 34 |
('Heatlth', 'http://www.upi.com/rss/NewsTrack/Health/'), |
| 35 |
('Quirks', 'http://www.upi.com/rss/NewsTrack/Quirks/'), |
| 36 |
] |
| 37 |
|
| 38 |
def print_version(self, url): |
| 39 |
return url + 'print/' |