Created
October 16, 2022 00:41
-
-
Save vdavez/5fba49d48a1b56da92ba4025f7a25189 to your computer and use it in GitHub Desktop.
Wisconsin Public Radio Calibre News Feed Recipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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