Skip to content

Instantly share code, notes, and snippets.

@vdavez
Created October 16, 2022 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdavez/5fba49d48a1b56da92ba4025f7a25189 to your computer and use it in GitHub Desktop.
Save vdavez/5fba49d48a1b56da92ba4025f7a25189 to your computer and use it in GitHub Desktop.
Wisconsin Public Radio Calibre News Feed Recipe
#!/usr/bin/env python
# vim:fileencoding=utf-8
from calibre.web.feeds.recipes import BasicNewsRecipe
class WPR(BasicNewsRecipe):
title = 'Wisconsin Public Radio'
author = 'V David Zvenyach'
description = 'Daily news from the Wisconsin Public Radio'
no_stylesheets = True
compress_news_images = True
keep_only_tags = [dict(name='div', attrs={'class':'block-main'})]
remove_tags= [
dict(name='div', attrs={'class':'block-inject'}),
dict(name='div', attrs={'class':'field-name-service-links-displays-group'})
]
def parse_index(self):
soup = self.index_to_soup('https://www.wpr.org/news/index.html')
articles = [
]
for div in soup.findAll('div', attrs={'class':'views-row'}):
h2 = div.find('h2')
if not h2:
continue
url = "https://www.wpr.org" + h2.a.get('href')
title = h2.get_text()
date = div.find('span',attrs={'class':'date-display-single'}).get_text()
description = ""
content = ""
articles.append(dict(
url=url,
title=title,
date=date,
description=description,
content=content
))
return [('WPR News', articles)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment