mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update India Today
This commit is contained in:
parent
bf43041b19
commit
99cecfb737
@ -10,8 +10,9 @@ class IndiaToday(BasicNewsRecipe):
|
|||||||
remove_attributes = ['style','height','width']
|
remove_attributes = ['style','height','width']
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
extra_css = '[itemprop^="description"] {font-size: small; font-style: italic;}'
|
extra_css = '[itemprop^="description"] {font-size: small; font-style: italic;}'
|
||||||
description = ('India’s Most Reputed, Credible and Popular news magazine.'
|
description = (
|
||||||
' Read the most preferred magazine of 9.5 million Indians to access highly researched and unbiased content.')
|
'India’s Most Reputed, Credible and Popular news magazine.'
|
||||||
|
' Read the most preferred magazine of 9.5 million Indians to access highly researched and unbiased content.')
|
||||||
masthead_url = 'https://akm-img-a-in.tosshub.com/sites/all/themes/itg/logo.png'
|
masthead_url = 'https://akm-img-a-in.tosshub.com/sites/all/themes/itg/logo.png'
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
@ -27,17 +28,17 @@ class IndiaToday(BasicNewsRecipe):
|
|||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
soup = self.index_to_soup('https://www.indiatoday.in/magazine')
|
soup = self.index_to_soup('https://www.indiatoday.in/magazine')
|
||||||
ans = self.it_parse_index(soup)
|
|
||||||
return ans
|
|
||||||
|
|
||||||
def it_parse_index(self, soup):
|
section = None
|
||||||
feeds = []
|
sections = {}
|
||||||
for section in soup.findAll('div', attrs={'class':['magazin-top-left', 'section-ordering']}):
|
|
||||||
sec = section.find('span')
|
for tag in soup.findAll('div', attrs={'class':['magazin-top-left', 'section-ordering']}):
|
||||||
secname = self.tag_to_string(sec)
|
sec = tag.find('span')
|
||||||
self.log(secname)
|
section = self.tag_to_string(sec)
|
||||||
articles = []
|
self.log(section)
|
||||||
for a in section.findAll('a', href=lambda x: x and x.startswith(("/magazine/cover-story/story/", "https://www.indiatoday.in/magazine/"))):
|
sections[section] = []
|
||||||
|
|
||||||
|
for a in tag.findAll('a', href=lambda x: x and x.startswith(("/magazine/cover-story/story/", "https://www.indiatoday.in/magazine/"))):
|
||||||
url = a['href']
|
url = a['href']
|
||||||
if url.startswith('https'):
|
if url.startswith('https'):
|
||||||
url = url
|
url = url
|
||||||
@ -49,11 +50,28 @@ class IndiaToday(BasicNewsRecipe):
|
|||||||
url = ''
|
url = ''
|
||||||
self.log('\t', title)
|
self.log('\t', title)
|
||||||
self.log('\t\t', url)
|
self.log('\t\t', url)
|
||||||
articles.append({
|
sections[section].append({
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': url})
|
'url': url})
|
||||||
if articles:
|
|
||||||
feeds.append((secname, articles))
|
feeds = []
|
||||||
|
|
||||||
|
# Insert feeds in specified order, if available
|
||||||
|
|
||||||
|
feedSort = ['EDITOR\'S NOTE', 'Cover Story', 'The Big Story', 'Upfront', 'NATION', 'INTERVIEW']
|
||||||
|
for i in feedSort:
|
||||||
|
if i in sections:
|
||||||
|
feeds.append((i, sections[i]))
|
||||||
|
|
||||||
|
# Done with the sorted feeds
|
||||||
|
|
||||||
|
for i in feedSort:
|
||||||
|
del sections[i]
|
||||||
|
|
||||||
|
# Append what is left over...
|
||||||
|
|
||||||
|
for i in sections:
|
||||||
|
feeds.append((i, sections[i]))
|
||||||
return feeds
|
return feeds
|
||||||
|
|
||||||
def preprocess_raw_html(self, raw_html, url):
|
def preprocess_raw_html(self, raw_html, url):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user