#!/usr/bin/python # Last updated: 27-Dec-2009 23:20 import sys import urllib import time import re from time import gmtime, strftime while True: # Get the last tweet id: last_page = urllib.urlopen("http://www.erichl.net/inquisidor/last.php") for linha in last_page : last = linha.split() last_id = int(last[0]) # Search for the tag search_page_url = "http://search.twitter.com/search.atom?q=%22meu%20deus%22&since_id="+last[0] search_page = urllib.urlopen(search_page_url) filestring = '' for linha in search_page: line = linha.split() if line: filestring += line[0] # Separate and analyse each result found entries = filestring.split("") for n in range(len(entries)-1, 0, -1): entry = entries[n] # First, analyse the tweet id quebra_id = re.split(":|", entry) id = int(quebra_id[2]) if id > last_id: last_id = id # Get the username quebra_usr = re.split("http://twitter.com/|", entry) user = quebra_usr[1] # Answer the tweet twt_url = "http://www.erichl.net/inquisidor/post.php?u="+user twt = urllib.urlopen(twt_url) # Verify if it was possible to tweet, if it wasn't, print the moment of the error for linha in twt : res = linha.split() if int(res[0]) == 0: print strftime("%a, %d %b %Y %H:%M:%S", gmtime()) if int(res[0]) == 1: print "ok" # Update last id last_page_url = "http://www.erichl.net/inquisidor/last.php?add="+str(last_id) last_page = urllib.urlopen(last_page_url) time.sleep(60) #print "%d %f" % (n, x)