Hi, I am trying to parse Twitter RSS feeds and put the information in a sqlite database, using Python. Here's an example:
u'MiamiPete: today\'s "Last Call" is now up http://bit.ly/MGDzu #stocks #stockmarket #finance #money'
What I want to do is create one column for the main content ("Miami Pete....now up)", one column for the URL ("http://bit.ly/MGDzu), and four separate columns for the hashtags (stocks, stockmarket, finance, money). I've been playing around with how to do this.
Any advice would be greatly appreciated!
Thanks,
Greg
P.S. Some code I've been playing around with is below--you can see I tried initially creating a variable called "tiny_url" and splitting it, which it does seem to do, but this feeble attempt is not anywhere close to solving the problem noted above. :)
def store_feed_items(id, items):
""" Takes a feed_id and a list of items and stored them in the DB """
for entry in items:
c.execute('SELECT entry_id from RSSEntries WHERE url=?', (entry.link,))
tinyurl = entry.summary ### I added this in
print tinyurl.split('http') ### I added this in
if len(c.fetchall()) == 0:
c.execute('INSERT INTO RSSEntries (id, url, title, content, tinyurl, date, tiny) VALUES (?,?,?,?,?,?,?)', (id, entry.link, entry.title, entry.summary, tinyurl, strftime("%Y-%m-%d %H:%M:%S",entry.updated_parsed), tiny ))