May 2012
M T W T F S S
« Jul «-»  
 123456
78910111213
14151617181920
21222324252627
28293031  

Leaving Chris World?

Why not bring back a souvenir?

Archives

The Short Feed

Dang. So far I can only obtain my feed back to

Sun, 25 Jan 2009 04:46:46 +0000

That's not good.

I need the whole thing thus far. I must need
a different interface.

 
"""
A bit more modification and data massage
to obtain just the dates and the descriptions in a list.
Not very elegant but it works. 
 
Also writes out the full xml so I can try mu luck with
java. 
 
Chris B Stones
January 17, 2009
modified January 27, 2009
"""
#http://twitter.com/statuses/user_timeline/18813776.rss
 
# What are we.. birds?
TWEET_FEED = "http://twitter.com/statuses/user_timeline/18813776.rss"
import urllib
from urllib import urlopen
a = urlopen(TWEET_FEED)
 
# I haven't written python code in a while so my
# software is lacking simple python elegance.
str = ''
for c in a:
	str += c
 
#save XML
f = open("savedata.xml",'w')
f.write(str)
f.close()
 
# I was delighted to find The element Tree was
# now included in python
# http://effbot.org/zone/element-index.htm
# http://docs.python.org/library/xml.etree.elementtree.html?highlight=xml#module-xml.etree.ElementTree
import xml.etree.ElementTree
 
flatfeed = ''
 
t = xml.etree.ElementTree.fromstring(str)
mytree = t.getiterator()
for n in mytree:
	# simplest way to just show that I have the XML for my feed
	# Print the descriptions and the dates
	if n.tag == 'description':
		raw = n.text
		flatfeed += raw.replace('sirhcsenots:','').strip() + '\n'
	if n.tag == 'pubDate':
		flatfeed += n.text + '\n'
		flatfeed += '\n'
 
output = open("flatfeed.txt",'w')
output.write(flatfeed)
output.close()
 

You must be logged in to post a comment.