3

This python script will get the current local trending topics.

Using Yahoo Weather get the WOEID of your city and replace it at https://api.twitter.com/1/trends/WOEID.xml

Use command "python /Users/xxxx/Documents/TT.py"

#!/usr/bin/python

import urllib2
from xml.dom.minidom import parseString

url="https://api.twitter.com/1/trends/23424900.xml"

file = urllib2.urlopen(url)
data = file.read()
file.close()
data = data.replace('%23', '#')
data = data.replace('%22', '')
data = data.replace('%20', ' ')

#parse xml
dom = parseString(data)

#loop through <entry> elements
entry=dom.getElementsByTagName('trend')
for node in entry:
    trend=node.getAttribute('query')

    print "%-20s" % (trend)

Based on the script Spanish Football - La Liga.


Comments

Log in to comment or register here.