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 06-16-2012, 05:39 PM   #1
terminalveracity
Member
terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.
 
Posts: 18
Karma: 6000
Join Date: Jun 2012
Device: Kindle Keyboard 3G
New recipe for National Geographic Magazine

This feed contains the main articles from the print magazine. Some of the miscellaneous topics (Your Shot, Wallpaper...) don't parse properly and are removed.

Spoiler:
Code:
import re
from calibre.web.feeds.recipes import BasicNewsRecipe

class NatGeoMag(BasicNewsRecipe):
    title                  = 'National Geographic Mag'
    __author__             = 'Terminal Veracity'
    description            = 'The National Geographic Magazine'
    publisher              = 'National Geographic'
    oldest_article         = 31
    max_articles_per_feed  = 50
    category               = 'geography, magazine'
    language               = 'en_US'
    publication_type       = 'magazine'
    cover_url              = 'http://www.yourlogoresources.com/wp-content/uploads/2011/09/national-geographic-logo.jpg'
    use_embedded_content   = False
    no_stylesheets         = True
    remove_javascript      = True
    recursions             = 1
    remove_empty_feeds     = True
    feeds                  = [('National Geographic Magazine', 'http://feeds.nationalgeographic.com/ng/NGM/NGM_Magazine')]
    remove_tags            = [dict(name='div', attrs={'class':['nextpage_continue', 'subscribe']})]
    keep_only_tags         = [dict(attrs={'class':'main_3narrow'})]
    extra_css              = """
                                h1 {font-size: large; font-weight: bold; margin: .5em 0; }
                                h2 {font-size: large; font-weight: bold; margin: .5em 0; }
                                h3 {font-size: medium; font-weight: bold; margin: 0 0; }
                                .article_credits_author {font-size: small; font-style: italic; }
                                .article_credits_photographer {font-size: small; font-style: italic; display: inline }
                             """

    def parse_feeds(self):
        feeds = BasicNewsRecipe.parse_feeds(self)
        for feed in feeds:
            for article in feed.articles[:]:
                if 'Flashback' in article.title:
                    feed.articles.remove(article)
                elif 'Desktop Wallpaper' in article.title:
                    feed.articles.remove(article)
                elif 'Visions of Earth' in article.title:
                    feed.articles.remove(article)
                elif 'Your Shot' in article.title:
                    feed.articles.remove(article)
                elif 'MyShot' in article.title:
                    feed.articles.remove(article)
                elif 'Field Test' in article.title:
                    feed.articles.remove(article)
        return feeds


Note:
The other National Geographic recipes make use of the news feed: http://feeds.nationalgeographic.com/ng/News/News_Main

This recipe uses the magazine feed: http://feeds.nationalgeographic.com/ng/NGM/NGM_Magazine
terminalveracity is offline   Reply With Quote
Old 06-23-2012, 01:13 AM   #2
Steven630
Zealot
Steven630 began at the beginning.
 
Posts: 142
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
Thank you. I was looking for a recipe for the magazine.
Steven630 is offline   Reply With Quote
Old 06-23-2012, 01:21 AM   #3
Steven630
Zealot
Steven630 began at the beginning.
 
Posts: 142
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
This recipe seems to catch past articles as well. I just tried and one article was from 2005. Wouldn't it be better to use to official TOC for each month?

http://ngm.nationalgeographic.com/20...le-of-contents
Steven630 is offline   Reply With Quote
Old 06-28-2012, 01:23 PM   #4
terminalveracity
Member
terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.
 
Posts: 18
Karma: 6000
Join Date: Jun 2012
Device: Kindle Keyboard 3G
Quote:
Originally Posted by Steven630 View Post
This recipe seems to catch past articles as well. I just tried and one article was from 2005.
It seems to be working properly for me and should only fetch articles from the last 31 days. Are you using the code I provided here? (The latest version of Calibre has it built in too as "National Geographic Mag".)

Quote:
Originally Posted by Steven630 View Post
Wouldn't it be better to use to official TOC for each month?
http://ngm.nationalgeographic.com/20...le-of-contents
While I suppose it's theoretically possible to scrape that page for each article, it's a lot easier to use RSS. The RSS feed contains the bulk of the text from the print version. I've intentionally removed the image galleries (Your Shot, Flashback...) as they're too complex and aren't going to look good on a little e-ink device anyhow.

terminalveracity is offline   Reply With Quote
Old 06-28-2012, 11:40 PM   #5
Steven630
Zealot
Steven630 began at the beginning.
 
Posts: 142
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
Yes, I was using the recipe you provided. It worked fine except that one of the articles fetched was from 2005. Perhaps, it was the problem with rss, not the recipe.

Last edited by Steven630; 06-28-2012 at 11:43 PM.
Steven630 is offline   Reply With Quote
Old 08-30-2012, 09:24 PM   #6
xfiles
Member
xfiles can extract oil from cheesexfiles can extract oil from cheesexfiles can extract oil from cheesexfiles can extract oil from cheesexfiles can extract oil from cheesexfiles can extract oil from cheesexfiles can extract oil from cheesexfiles can extract oil from cheese
 
xfiles's Avatar
 
Posts: 12
Karma: 1000
Join Date: May 2011
Device: kindle
Post NatGeo Mobile

I have a Google Chrome browser extension for National Geographic Magazine (link Barry Welch autor), mobile version.

Is it possible to make a recipe based on this extension? At least use the feed. I think that this feed contains more content than the previous recipes.

xfiles is offline   Reply With Quote
Old 09-01-2012, 02:34 AM   #7
terminalveracity
Member
terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.terminalveracity got an A in P-Chem.
 
Posts: 18
Karma: 6000
Join Date: Jun 2012
Device: Kindle Keyboard 3G
Quote:
Originally Posted by xfiles View Post
I have a Google Chrome browser extension for National Geographic Magazine (link Barry Welch autor), mobile version.

Is it possible to make a recipe based on this extension? At least use the feed. I think that this feed contains more content than the previous recipes.

That extension is a fraud. It's nothing more than a frame linking to the NatGeo mobile site with ads bolted on. Bookmark > Extension.

As for content, the 2 existing recipes are far superior. The NatGeo mobile site only has a small subset of articles from the main news feed. The recipe named "National Geographic" uses the full news feed (shorter articles, more frequent new content) and "National Geographic Mag" uses the magazine feed (longer articles, less frequent new content).
terminalveracity is offline   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
National Geographic Spain (es) vakya Recipes 4 05-18-2012 02:19 PM
Would it be possible to get a recipe for National Geographic Mag? Gnome Eater Recipes 6 11-19-2011 04:23 PM
National Geographic (DE) xXxXxXxXxXx Recipes 0 05-21-2011 08:56 AM
Recipe for National Geographic *Updated* gagsays Recipes 3 05-19-2011 12:30 PM
National Geographic Recipe (need some improvement) gagsays Recipes 6 05-19-2011 12:21 PM


All times are GMT -4. The time now is 10:46 AM.


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