mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Updated recipe for Outlook India
This commit is contained in:
parent
6261ba3f72
commit
8dd752d850
@ -3,6 +3,8 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import re
|
import re
|
||||||
|
from calibre import strftime
|
||||||
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class OutlookIndia(BasicNewsRecipe):
|
class OutlookIndia(BasicNewsRecipe):
|
||||||
@ -13,10 +15,19 @@ class OutlookIndia(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
language = _('English')
|
language = _('English')
|
||||||
|
recursions = 1
|
||||||
|
extra_css = '''
|
||||||
|
body{font-family:Arial,Helvetica,sans-serif; font-size:xx-small;}
|
||||||
|
.fspheading{color:#AF0E25 ; font-family:"Times New Roman",Times,serif; font-weight:bold ; font-size:large; }
|
||||||
|
.fspauthor{color:#AF0E25; font-family:Arial,Helvetica,sans-serif; font-size:xx-small;}
|
||||||
|
.fspintro{color:#666666; font-family:Arial,Helvetica,sans-serif; font-size:xx-small;}
|
||||||
|
.fspchannelhome{font-family:Arial,Helvetica,sans-serif; font-size:x-small;}
|
||||||
|
.fspphotocredit{color:##999999; font-family:Arial,Helvetica,sans-serif; font-size:xx-small;}
|
||||||
|
'''
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
dict(name='div', attrs={'id':["ctl00_cphpagemiddle_reparticle_ctl00_divfullstorytext","ctl00_cphpagemiddle_reparticle_ctl00_divartpic","ctl00_cphpagemiddle_reparticle_ctl00_divfspheading", "ctl00_cphpagemiddle_reparticle_ctl00_divartpiccaption", "ctl00_cphpagemiddle_reparticle_ctl00_divartpiccredit","ctl00_cphpagemiddle_reparticle_ctl00_divfspintro", "ctl00_cphpagemiddle_reparticle_ctl00_divartbyline", ]}),
|
dict(name='div', attrs={'id':["ctl00_cphpagemiddle_reparticle_ctl00_divfullstorytext","ctl00_cphpagemiddle_reparticle_ctl00_divartpic","ctl00_cphpagemiddle_reparticle_ctl00_divfspheading", "ctl00_cphpagemiddle_reparticle_ctl00_divartpiccaption", "ctl00_cphpagemiddle_reparticle_ctl00_divartpiccredit","ctl00_cphpagemiddle_reparticle_ctl00_divfspintro", "ctl00_cphpagemiddle_reparticle_ctl00_divartbyline", "ctl00_cphpagemiddle_divglitteratiregulars","ctl00_cphpagemiddle_divcartoon","feedbackslatestfirst","ctl00_cphpagemiddle_divregulars","ctl00_cphpagemiddle_divquotes"]}),
|
||||||
]
|
]
|
||||||
remove_tags = [dict(name=['script','object'])]
|
remove_tags = [dict(name=['script','object','hr']),]
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
@ -27,12 +38,11 @@ class OutlookIndia(BasicNewsRecipe):
|
|||||||
br.set_cookiejar(None)
|
br.set_cookiejar(None)
|
||||||
return br
|
return br
|
||||||
|
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
|
|
||||||
|
|
||||||
soup = self.index_to_soup('http://www.outlookindia.com/issues.aspx')
|
soup = self.index_to_soup('http://www.outlookindia.com/issues.aspx')
|
||||||
# find cover pic
|
# find cover pic
|
||||||
div = soup.find('div', attrs={'class':re.compile('cententcellpadding')})
|
div = soup.find('div', attrs={'class':re.compile('cententcellpadding')})
|
||||||
|
|
||||||
if div is None: return None
|
if div is None: return None
|
||||||
@ -47,8 +57,8 @@ class OutlookIndia(BasicNewsRecipe):
|
|||||||
|
|
||||||
self.cover_url = cover['src']
|
self.cover_url = cover['src']
|
||||||
|
|
||||||
# end find cover pic
|
# end find cover pic
|
||||||
|
#find current issue
|
||||||
div = soup.find('table', attrs={'id':re.compile('ctl00_cphpagemiddle_dlissues')})
|
div = soup.find('table', attrs={'id':re.compile('ctl00_cphpagemiddle_dlissues')})
|
||||||
|
|
||||||
if div is None: return None
|
if div is None: return None
|
||||||
@ -58,25 +68,48 @@ class OutlookIndia(BasicNewsRecipe):
|
|||||||
href = 'http://www.outlookindia.com/' + a['href']
|
href = 'http://www.outlookindia.com/' + a['href']
|
||||||
|
|
||||||
soup = self.index_to_soup(href)
|
soup = self.index_to_soup(href)
|
||||||
|
#find current issue
|
||||||
|
|
||||||
|
#find the articles in the current issue
|
||||||
articles = []
|
articles = []
|
||||||
|
|
||||||
for a in soup.findAll('a', attrs={'class':'contentpgsubheadinglink'}):
|
for a in soup.findAll('a', attrs={'class':['contentpgsubheadinglink',"contentpgtext6",]}):
|
||||||
|
|
||||||
if a and a.has_key('href'):
|
if a and a.has_key('href'):
|
||||||
|
|
||||||
url = 'http://www.outlookindia.com/' + a['href']
|
url = 'http://www.outlookindia.com/' + a['href']
|
||||||
else:
|
else:
|
||||||
url =''
|
url =''
|
||||||
|
|
||||||
title = self.tag_to_string(a)
|
title = self.tag_to_string(a)
|
||||||
|
|
||||||
|
desc = ''
|
||||||
date = ''
|
date = ''
|
||||||
description = ''
|
|
||||||
articles.append({
|
articles.append({
|
||||||
'title':title,
|
'title':title,
|
||||||
'date':date,
|
'date':date,
|
||||||
'url':url,
|
'url':url,
|
||||||
'description':description
|
'description':desc,
|
||||||
})
|
})
|
||||||
|
for a in soup.findAll('a', attrs={'id':["ctl00_cphpageleft_hlglitterati","ctl00_cphpageleft_hlposcape",]}):
|
||||||
|
|
||||||
|
if a and a.has_key('href'):
|
||||||
|
|
||||||
|
url = 'http://www.outlookindia.com/' + a['href']
|
||||||
|
else:
|
||||||
|
url =''
|
||||||
|
|
||||||
|
title = self.tag_to_string(a)
|
||||||
|
|
||||||
|
desc = ''
|
||||||
|
date = ''
|
||||||
|
articles.append({
|
||||||
|
'title':title,
|
||||||
|
'date':date,
|
||||||
|
'url':url,
|
||||||
|
'description':desc,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
return [('Current Issue', articles)]
|
return [('Current Issue', articles)]
|
||||||
|
|
||||||
@ -85,11 +118,15 @@ class OutlookIndia(BasicNewsRecipe):
|
|||||||
del item['style']
|
del item['style']
|
||||||
return self.adeify_images(soup)
|
return self.adeify_images(soup)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def postrocess_html(self, soup, first):
|
def postrocess_html(self, soup, first):
|
||||||
|
|
||||||
for tag in soup.findAll(name=['table', 'tr', 'td','tbody']):
|
for item in soup.findAll(align = "left"):
|
||||||
tag.name = 'div'
|
del item['align']
|
||||||
|
|
||||||
|
for tag in soup.findAll(name=['table', 'tr','td','tbody','ul','li','font','span']):
|
||||||
|
tag.name = 'div'
|
||||||
|
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user