02-24-2011, 09:57 PM | #1 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2011
Device: Kindle 3
|
Create Article Sections From Feed?
Hi Everyone,
I have a local newspaper that lists all sections in the same feed: http://www.mahopacnews.com/rssheadlines.xml I have the following recipe to grab the articles Spoiler:
However I get all the articles in one section. I would like to split the articles into their appropriate sections (News, Sports, Opinions, etc). On the feed page each article has the appropriate section name at the beginning of the article title. Eample: News: Wild guest wows Mahopac Middle School students News: Can Rotary Dream Team beat Harlem Magic Masters this year on March 11? Opinion: Dressing for the next ice age I added the following to the recipe which allowed me to filter the articles based upon a key word in the title: Code:
def get_article_url(self, article): link = article.get('link') title = article.get('title') if 'News:' in title: return link Last edited by Finbar127; 02-24-2011 at 10:05 PM. |
02-25-2011, 07:48 AM | #2 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
https://www.mobileread.com/forums/sho...45&postcount=2 |
|
Advert | |
|
02-25-2011, 05:21 PM | #3 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2011
Device: Kindle 3
|
Thanks. I tried adjusting that code to fit my recipe and I ended up with this:
Spoiler:
I get the following error: line 32, in parse_feeds pfeed = Feed() NameError: global name 'Feed' is not defined Do you know where I would define Feed in the recipe? Also Could you point me to a recipe where this particular chunk of code is used? Last edited by Finbar127; 02-25-2011 at 05:28 PM. |
02-25-2011, 08:54 PM | #4 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Reader's Digest follows: Spoiler:
Last edited by Starson17; 02-25-2011 at 09:21 PM. |
|
02-26-2011, 12:18 AM | #5 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2011
Device: Kindle 3
|
Thanks again. Like you said my recipe was missing the following line:
Code:
from calibre.web.feeds import Feed Here is the working recipe. It can probably be optimized but it basically works and the resulting file looks great on my Kindle3: Spoiler:
Last edited by Finbar127; 02-26-2011 at 12:21 AM. |
Advert | |
|
02-26-2011, 08:55 AM | #6 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
I added the import to the sticky code post, so others will be able to find it easily. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create clean custom Yahoo Rss feed | 77ja55 | Recipes | 1 | 01-17-2011 09:33 AM |
Decorate article headings as hyperlinks to full article? | tomsem | Recipes | 5 | 10-15-2010 08:30 PM |
How to create RSS feed for blogs? | mishicka | Calibre | 2 | 02-11-2010 11:48 AM |
New Forum Sections | gvtexas | Announcements | 1 | 06-09-2003 09:05 AM |