Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 10-18-2020, 12:35 PM   #1
epubli
Enthusiast
epubli began at the beginning.
 
Posts: 25
Karma: 10
Join Date: Nov 2012
Device: Pocketbook Inkpad 3
How to remove an article which contains "this article was sponsored" in the text ?

Some feeds have articles which contain advertisements. I would like to remove the articles from the feed based on some string in the content like "this article was sponsored by".

How can this be achieved ?


Up to I tried to check the article content in parse_feeds() but this does not work. I think there is not yet anything in article.content:

Spoiler:

def parse_feeds(self):
# Call parent's method.
feeds = BasicNewsRecipe.parse_feeds(self)
# Loop through all feeds.
for feed in feeds:
# Loop through all articles in feed.
for article in feed.articles[:]:
# Remove sponsored articles
if 'this article was sponsored' in article.content:
feed.articles.remove(article)
return feeds


Any help is appreciated.
epubli is offline   Reply With Quote
Old 10-18-2020, 01:02 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,260
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Implement preprocess_raw_html in your recipeand call self.abort_article() inside it if you want to skip the article.
kovidgoyal is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Yikes: "this article was downloaded by calibre" after every article sheygetz Calibre 11 05-29-2015 02:56 AM
include "This article was downloaded by calibre from" for tablet profile Purple Lady Recipes 10 06-23-2013 01:28 AM
Remove "This article was downloaded by calibre from..." peonazerty Recipes 1 05-27-2013 08:40 AM
Article on Plastic Logic in german magazine "Der Spiegel" Manichean News 1 09-18-2008 06:48 AM
Ebook article/review on pocketlint UK "ebooks taking over the paper" stustaff News 4 07-07-2008 08:05 AM


All times are GMT -4. The time now is 04:29 AM.


MobileRead.com is a privately owned, operated and funded community.