| 1 |
__license__ = 'GPL v3' |
| 2 |
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>' |
| 3 |
''' |
| 4 |
azstarnet.com |
| 5 |
''' |
| 6 |
try: |
| 7 |
from urllib.parse import urlencode |
| 8 |
except ImportError: |
| 9 |
from urllib import urlencode |
| 10 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 11 |
|
| 12 |
|
| 13 |
class Azstarnet(BasicNewsRecipe): |
| 14 |
title = 'Arizona Daily Star' |
| 15 |
__author__ = 'Darko Miletic' |
| 16 |
description = 'news from Arizona' |
| 17 |
language = 'en' |
| 18 |
publisher = 'azstarnet.com' |
| 19 |
category = 'news, politics, Arizona, USA' |
| 20 |
oldest_article = 3 |
| 21 |
max_articles_per_feed = 100 |
| 22 |
no_stylesheets = True |
| 23 |
use_embedded_content = False |
| 24 |
encoding = 'utf-8' |
| 25 |
masthead_url = 'http://azstarnet.com/content/tncms/live/global/resources/images/logo.gif' |
| 26 |
needs_subscription = True |
| 27 |
|
| 28 |
conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language} |
| 29 |
|
| 30 |
def get_browser(self): |
| 31 |
br = BasicNewsRecipe.get_browser(self) |
| 32 |
br.open('http://azstarnet.com/') |
| 33 |
if self.username is not None and self.password is not None: |
| 34 |
data = urlencode({'m': 'login', 'u': self.username, 'p': self.password, 'z': 'http://azstarnet.com/'}) |
| 35 |
br.open('http://azstarnet.com/app/registration/proxy.php', data) |
| 36 |
return br |
| 37 |
|
| 38 |
remove_tags = [dict(name=['object', 'link', 'iframe', 'base', 'img'])] |
| 39 |
|
| 40 |
feeds = [ |
| 41 |
('Local News', 'http://azstarnet.com/search/?f=rss&t=article&c=news/local&l=25&s=start_time&sd=desc'), |
| 42 |
('National News', 'http://azstarnet.com/search/?f=rss&t=article&c=news/national&l=25&s=start_time&sd=desc'), |
| 43 |
('World News', 'http://azstarnet.com/search/?f=rss&t=article&c=news/world&l=25&s=start_time&sd=desc'), |
| 44 |
('Sports', 'http://azstarnet.com/search/?f=rss&t=article&c=sports&l=25&s=start_time&sd=desc'), |
| 45 |
('Opinion', 'http://azstarnet.com/search/?f=rss&t=article&c=news/opinion&l=25&s=start_time&sd=desc'), |
| 46 |
('Movies', 'http://azstarnet.com/search/?f=rss&t=article&c=entertainment/movies&l=25&s=start_time&sd=desc'), |
| 47 |
('Food', 'http://azstarnet.com/search/?f=rss&t=article&c=lifestyles/food-and-cooking&l=25&s=start_time&sd=desc'), |
| 48 |
] |
| 49 |
|
| 50 |
def preprocess_html(self, soup): |
| 51 |
for item in soup.findAll(style=True): |
| 52 |
del item['style'] |
| 53 |
return soup |
| 54 |
|
| 55 |
def print_version(self, url): |
| 56 |
return url + '?print=1' |