Bacalah

Learning is forever

RSS Feed

Going where this year?

My First Python Script, search on People’s Twit

0 Comments
Posted by Taufiq on May 19, 2011 at 11:28 am
import urllib
import xml.dom.minidom as minidom
 
def printTweets(username):
    jumlah = 20
    timeline_xml = urllib.urlopen("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=%s&count=%s" % (username, jumlah))
    xml = minidom.parse(timeline_xml)
    status = xml.getElementsByTagName("text")
 
    for twit in status:
        mau_dicari = twit.childNodes[0].data
        mau_cari = mau_dicari.find(cari)
        if mau_cari != -1 :
            print "tweet:",twit.childNodes[0].data,"\n"
        else :
            pass
 
user = raw_input("masukkan nama user\n")
cari = raw_input("masukkan yang tweet ingin dicari\n")
printTweets(user)

Good for stalking, without additional libraries, just install python, and run it. Find on 200 latest twit (the current API limit). Big thank to Mas Bima dan Mas Glowing Mind.

nb. untuk sementara hanya berjalan pada Python 2.xx

You can leave a comment, or trackback from your own site.

0 Comments

You can be the first to comment!

Leave a Reply

Your email address will not be published. Required fields are marked *