mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update General Knowledge Today
This commit is contained in:
parent
5f8eb3ce73
commit
550a633a3e
@ -7,7 +7,6 @@ class Politics(BasicNewsRecipe):
|
|||||||
__author__ = 'Kovid Goyal'
|
__author__ = 'Kovid Goyal'
|
||||||
oldest_article = 7 # days
|
oldest_article = 7 # days
|
||||||
max_articles_per_feed = 20
|
max_articles_per_feed = 20
|
||||||
use_embedded_content = False
|
|
||||||
|
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
no_javascript = True
|
no_javascript = True
|
||||||
@ -15,7 +14,7 @@ class Politics(BasicNewsRecipe):
|
|||||||
|
|
||||||
def parse_gkt_section(self, url):
|
def parse_gkt_section(self, url):
|
||||||
root = self.index_to_soup(url, as_tree=True)
|
root = self.index_to_soup(url, as_tree=True)
|
||||||
for a in root.xpath('//h1[@class="post-title"]/a[@href]'):
|
for a in root.xpath('//div[@class="post-content"]/h1/a[@href]'):
|
||||||
title = self.tag_to_string(a).strip()
|
title = self.tag_to_string(a).strip()
|
||||||
url = a.get('href')
|
url = a.get('href')
|
||||||
if title and url:
|
if title and url:
|
||||||
@ -26,14 +25,15 @@ class Politics(BasicNewsRecipe):
|
|||||||
url = 'http://www.gktoday.in/'
|
url = 'http://www.gktoday.in/'
|
||||||
root = self.index_to_soup(url, as_tree=True)
|
root = self.index_to_soup(url, as_tree=True)
|
||||||
ans = []
|
ans = []
|
||||||
for h3 in root.xpath('//h3[@class="widget-title" and contains(text(), "Current Affairs Category")]'):
|
h3 = root.xpath('//h3[@class="widget-title"]')[1]
|
||||||
for a in h3.getparent().xpath('descendant::li/a[@href]'):
|
for a in h3.getparent().xpath('descendant::li/a[@href]'):
|
||||||
category = self.tag_to_string(a).strip()
|
category = self.tag_to_string(a).strip()
|
||||||
url = a.get('href')
|
if 'PDF' in category:
|
||||||
self.log('Found section:', category)
|
continue
|
||||||
articles = list(self.parse_gkt_section(url)) + \
|
url = a.get('href')
|
||||||
list(self.parse_gkt_section(url + '/page/2'))
|
self.log('Found section:', category)
|
||||||
if articles:
|
articles = list(self.parse_gkt_section(url)) + \
|
||||||
ans.append((category, articles))
|
list(self.parse_gkt_section(url + '/page/2'))
|
||||||
break
|
if articles:
|
||||||
|
ans.append((category, articles))
|
||||||
return ans
|
return ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user