| 1 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 2 |
|
| 3 |
|
| 4 |
class TheFridayTimes(BasicNewsRecipe): |
| 5 |
__author__ = 'Krittika Goyal, ireadtheinternet' |
| 6 |
language = 'en_PK' |
| 7 |
encoding = 'utf8' |
| 8 |
version = 1.1 |
| 9 |
|
| 10 |
title = 'The Friday Times' |
| 11 |
category = 'news, Pakistan' |
| 12 |
description = "Pakistan's First Independent Weekly Paper" |
| 13 |
|
| 14 |
no_stylesheets = True |
| 15 |
no_javascript = True |
| 16 |
ignore_duplicate_articles = {'url'} |
| 17 |
|
| 18 |
keep_only_tags = [ |
| 19 |
dict(name='div', attrs={'class': 'sidebar_content'}), |
| 20 |
] |
| 21 |
|
| 22 |
remove_tags = [dict(name='p', attrs={'class': 'no-break'}), dict(name='div', attrs={'class': 'related_posts'}), dict(name='div', attrs={'id': 'respond'})] |
| 23 |
|
| 24 |
def parse_index(self): |
| 25 |
toc_page = self.index_to_soup('http://www.thefridaytimes.com/tft/') |
| 26 |
toc = toc_page.find('div', attrs={'class': 'sidebar_left_home_wrapper'}) |
| 27 |
|
| 28 |
articles = [] |
| 29 |
for story in toc.findAll('a'): |
| 30 |
# skip the links with an image, they are repeated further down |
| 31 |
if story.find('img') is not None: |
| 32 |
continue |
| 33 |
url = story['href'] |
| 34 |
# If no title, use url as title |
| 35 |
title = story.get('title', url) |
| 36 |
self.log('Found article:', story) |
| 37 |
self.log('\t', url) |
| 38 |
articles.append({'title': title, 'url': url, 'date': '', 'description': ''}) |
| 39 |
|
| 40 |
return [('Current Issue', articles)] |