Register Guidelines E-Books Search Today's Posts Mark Forums Read

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
Member
epubli began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Nov 2012
Device: Pocketbook611
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: 37,913
Karma: 16793211
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 online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:13 AM.


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