Skip to content

Commit

Permalink
Update General Knowledge Today
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Oct 20, 2018
1 parent 5f8eb3c commit 550a633
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions recipes/gkt.recipe
Expand Up @@ -7,15 +7,14 @@ class Politics(BasicNewsRecipe):
__author__ = 'Kovid Goyal'
oldest_article = 7 # days
max_articles_per_feed = 20
use_embedded_content = False

no_stylesheets = True
no_javascript = True
auto_cleanup = True

def parse_gkt_section(self, url):
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()
url = a.get('href')
if title and url:
Expand All @@ -26,14 +25,15 @@ class Politics(BasicNewsRecipe):
url = 'http://www.gktoday.in/'
root = self.index_to_soup(url, as_tree=True)
ans = []
for h3 in root.xpath('//h3[@class="widget-title" and contains(text(), "Current Affairs Category")]'):
for a in h3.getparent().xpath('descendant::li/a[@href]'):
category = self.tag_to_string(a).strip()
url = a.get('href')
self.log('Found section:', category)
articles = list(self.parse_gkt_section(url)) + \
list(self.parse_gkt_section(url + '/page/2'))
if articles:
ans.append((category, articles))
break
h3 = root.xpath('//h3[@class="widget-title"]')[1]
for a in h3.getparent().xpath('descendant::li/a[@href]'):
category = self.tag_to_string(a).strip()
if 'PDF' in category:
continue
url = a.get('href')
self.log('Found section:', category)
articles = list(self.parse_gkt_section(url)) + \
list(self.parse_gkt_section(url + '/page/2'))
if articles:
ans.append((category, articles))
return ans

0 comments on commit 550a633

Please sign in to comment.