Skip to content
Newer
Older
100644 33 lines (26 sloc) 1.14 KB
aa71a60 AP-Feed
Craig Weber authored
1 #AP-Feed
2
3 A basic wrapper around the AssociatedPress's XML feed. Included are some sample feed files
4
e171670 readme
Craig Weber authored
5 ###Spec:
aa71a60 AP-Feed
Craig Weber authored
6 A simple python library that does the following, given the XML feed for a category:
7
e171670 readme
Craig Weber authored
8 Return a list of each story in the feed, where the story (can be Class or Dict, doesn't matter) has the following fields:
9
10 * Unique ID
11 * Title: Plain text, no HTML
12 * Summary: Use the plain text (no HTML) from the first paragraph, without the location and author information (e.g. NEW YORK (AP) --)
13 * Date
14 * Images: List of images in the article, with each having:
15 * Caption (not including any credit information, like AP Photo)
16 * Credit information
17 * URL to the image
13f4389 readme
Craig Weber authored
18 * Content: The HTML content of the article. Strip the surrounding `<div>` such that it's just a sequence of `<p>` tags. Also:
e171670 readme
Craig Weber authored
19 * Add class='first' to the first paragraph
20 * Add class='last' to the final paragraph
21
22 ###Notes:
188b49c Fixed README
Craig Weber authored
23 Returns a Class
aa71a60 AP-Feed
Craig Weber authored
24
e171670 readme
Craig Weber authored
25 ###Usage (provide XML):
188b49c Fixed README
Craig Weber authored
26 from associatedpress import ap
27 ap = parse(xml = feed_xml)
28 stories = ap.parse()
aa71a60 AP-Feed
Craig Weber authored
29
e171670 readme
Craig Weber authored
30 ###Usage (provide URL):
188b49c Fixed README
Craig Weber authored
31 from associatedpress import ap
32 ap = parse(url = "http://example.com/feed.xml")
33 stories = ap.parse()
Something went wrong with that request. Please try again.