<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eddie On Everything &#187; associated press</title>
	<atom:link href="http://www.eddieoneverything.com/tag/associated-press/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eddieoneverything.com</link>
	<description>Don&#039;t get me started</description>
	<lastBuildDate>Mon, 23 Aug 2010 16:19:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Customizing the Calibre Associated Press (AP) Recipe</title>
		<link>http://www.eddieoneverything.com/programming/customizing-the-calibre-associated-press-ap-recipe.php</link>
		<comments>http://www.eddieoneverything.com/programming/customizing-the-calibre-associated-press-ap-recipe.php#comments</comments>
		<pubDate>Mon, 22 Feb 2010 16:48:18 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[amazon kindle]]></category>
		<category><![CDATA[AP]]></category>
		<category><![CDATA[associated press]]></category>
		<category><![CDATA[calibre]]></category>
		<category><![CDATA[calibre recipes]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[kindle]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=761</guid>
		<description><![CDATA[I&#8217;ve been using Calibre to manage my eBook library and download daily news to my Kindle.   It&#8217;s great.  If you have a Kindle or other eBook reader, I recommend that you check it out.
Calibre comes stocked with a number of &#8220;recipes&#8221; for popular news sites.  One of those is the Associated Press (AP).  Since [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Calibre to manage my eBook library and download daily news to my Kindle.   It&#8217;s great.  If you have a Kindle or other eBook reader, I recommend that you check it out.</p>
<p>Calibre comes stocked with a number of &#8220;recipes&#8221; for popular news sites.  One of those is the Associated Press (AP).  Since the AP creates a good deal of the news in many popular dailies,  I&#8217;ve found the AP recipe most useful.</p>
<p>I noticed today, though, that the AP recipe that comes with Calibre is incomplete!  It omits at least three sections, Sports, Business, and Entertainment.  I don&#8217;t know if the creator, Kovid Goyal,  just doesn&#8217;t like these sections, or if they weren&#8217;t available when he wrote the original recipe.</p>
<p>(When I wrote my <a href="http://www.eddieoneverything.com/programming/calibre-recipe-for-minneapolis-star-tribune-startribune-com.php" target="_blank">custom recipe for the Minneapolis Star-Tribune</a>, I omitted the sections that weren&#8217;t of interest to me.)</p>
<p>In any event, I&#8217;ve customized his recipe script to include the omitted sections.  It was a very easy customization &#8211; I only had to add three lines to the original python script.  The only tricky part was picking a local &#8220;news source&#8221; for the AP&#8217;s RSS feed &#8211; otherwise, the AP site serves up a random source, which can lead to problems with processing the page.</p>
<pre name="code" class="python">
import re
from calibre.web.feeds.news import BasicNewsRecipe

class AssociatedPress(BasicNewsRecipe):

    title = u'Associated Press'
    description = 'Global news'
    __author__ = 'Kovid Goyal'
    use_embedded_content   = False
    language = 'en'

    max_articles_per_feed = 15
    html2lrf_options = ['--force-page-break-before-tag="chapter"']

    preprocess_regexps = [ (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) for i in
[
        (r'<HEAD>.*?</HEAD>' , lambda match : '<HEAD></HEAD>'),
        (r'<body class="apple-rss-no-unread-mode" onLoad="setup(null)">.*?<!-- start Entries -->', lambda match : '<body>'),
        (r'<!-- end apple-rss-content-area -->.*?</body>', lambda match : '</body>'),
        (r'<script.*?>.*?</script>', lambda match : ''),
        (r'<body.*?>.*?<span class="headline">', lambda match : '<body><span class="headline"><chapter>'),
        (r'
<tr>
<td>
<div class="body">.*?
<p class="ap-story-p">', lambda match : '
<p class="ap-story-p">'),
        (r'
<p class="ap-story-p">', lambda match : '

'),
        (r'Learn more about our <a href="http://apdigitalnews.com/privacy.html">Privacy Policy</a>.*?</body>', lambda match : '</body>'),
    ]
    ]   

    feeds = [ ('AP Headlines', 'http://hosted.ap.org/lineups/TOPHEADS-rss_2.0.xml?SITE=ORAST&#038;SECTION=HOME'),
                  ('AP US News', 'http://hosted.ap.org/lineups/USHEADS-rss_2.0.xml?SITE=CAVIC&#038;SECTION=HOME'),
                   ('AP World News', 'http://hosted.ap.org/lineups/WORLDHEADS-rss_2.0.xml?SITE=SCAND&#038;SECTION=HOME'),
                   ('AP Political News', 'http://hosted.ap.org/lineups/POLITICSHEADS-rss_2.0.xml?SITE=ORMED&#038;SECTION=HOME'),
                   ('AP Business News', 'http://hosted.ap.org/lineups/BUSINESSHEADS-rss_2.0.xml?SITE=RANDOM&#038;SECTION=HOME'),
                   ('AP Technology News', 'http://hosted.ap.org/lineups/TECHHEADS-rss_2.0.xml?SITE=CTNHR&#038;SECTION=HOME'),
                   ('AP Sports News', 'http://hosted.ap.org/lineups/SPORTSHEADS-rss_2.0.xml?SITE=CAVIC&#038;SECTION=HOME'),
                   ('AP Business News', 'http://hosted.ap.org/lineups/BUSINESSHEADS-rss_2.0.xml?SITE=CAVIC&#038;SECTION=HOME'),
                   ('AP Entertainment News', 'http://hosted.ap.org/lineups/ENTERTAINMENT-rss_2.0.xml?SITE=CAVIC&#038;SECTION=HOME'),
                   ('AP Science News', 'http://hosted.ap.org/lineups/SCIENCEHEADS-rss_2.0.xml?SITE=OHCIN&#038;SECTION=HOME'),
                   ('AP Strange News', 'http://hosted.ap.org/lineups/STRANGEHEADS-rss_2.0.xml?SITE=WCNC&#038;SECTION=HOME'),
        ]
</pre>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/programming/calibre-recipe-for-minneapolis-star-tribune-startribune-com.php" title="Calibre Recipe for Minneapolis Star Tribune (StarTribune.com)">Calibre Recipe for Minneapolis Star Tribune (StarTribune.com)</a></li><li><a href="http://www.eddieoneverything.com/articles/getting-a-list-of-all-books-in-your-calibre-library.php" title="Getting a List of All Books in Your Calibre Library">Getting a List of All Books in Your Calibre Library</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-tell-if-someone-is-lying-about-their-ipad-experience.php" title="How To Tell If Someone Is Lying About Their iPad Experience">How To Tell If Someone Is Lying About Their iPad Experience</a></li><li><a href="http://www.eddieoneverything.com/articles/adding-a-confirm-dialog-to-instapapers-read-later-bookmarklet.php" title="Adding a Confirm Dialog To Instapaper&#8217;s &#8220;Read Later&#8221; Bookmarklet">Adding a Confirm Dialog To Instapaper&#8217;s &#8220;Read Later&#8221; Bookmarklet</a></li><li><a href="http://www.eddieoneverything.com/articles/viewing-the-clock-on-the-kindle-2.php" title="Viewing the Clock on the Kindle 2">Viewing the Clock on the Kindle 2</a></li><li><a href="http://www.eddieoneverything.com/articles/recently-read-documents-appearing-at-end-of-list-on-kindle.php" title="Recently Read Documents Appearing at End of List on Kindle">Recently Read Documents Appearing at End of List on Kindle</a></li><li><a href="http://www.eddieoneverything.com/articles/use-custom-background-images-as-screen-savers-on-the-kindle.php" title="Use Custom Background Images as Screen Savers on the Kindle">Use Custom Background Images as Screen Savers on the Kindle</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/programming/customizing-the-calibre-associated-press-ap-recipe.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
