Created
August 1, 2011 16:38
-
-
Save nsisodiya/1118478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#By - Narendra Sisodiya - http://narendrasisodiya.com | |
from urllib import urlopen | |
import xml.dom.minidom | |
import re | |
def Get_Total_Tweets(user): | |
URL="http://api.twitter.com/1/statuses/user_timeline.xml?include_entities=false&include_rts=true&count=1&screen_name=" + user | |
dom = xml.dom.minidom.parse(urlopen(URL)) | |
nodelist=dom.getElementsByTagName("statuses_count") | |
return nodelist[0].firstChild.nodeValue | |
def Get_Last_updated_tweet(user): | |
f=open("last/" + user, "r") | |
for r in f: | |
A=r.rstrip('\n') | |
f.close() | |
return A | |
def GetLinks(url): | |
dom = xml.dom.minidom.parse(urlopen(url)) | |
nodelist=dom.getElementsByTagName("description") | |
for node in nodelist: | |
Get_URL_FromText(node.firstChild.nodeValue) | |
def Get_URL_FromText(text): | |
text = text.replace('\n',' ') | |
b=text.split(' ') | |
Re = re.compile("http://") | |
for x in b: | |
m = Re.search(x) | |
if m != None: | |
print text | |
#print urlopen("http://api.twitter.com/1/statuses/user_timeline.xml?include_entities=false&include_rts=true&screen_name=nsisodiya&count=1").read() | |
## #TODO -- http://eubolist.wordpress.com/2010/12/24/python-script-merge-and-sort-multiple-rss-feed-items-in-one-feed/ | |
print "Welcome to Linux Links" | |
file_listuser=open('listuser', 'r') | |
for user in file_listuser: | |
user = user.rstrip('\n') | |
TotalTweets = Get_Total_Tweets(user) | |
LastTweets = Get_Last_updated_tweet(user) | |
Count = int(TotalTweets) - int(LastTweets) | |
print Count | |
if (Count == 0 ): | |
print "no need to update" | |
else: | |
GetLinks("http://api.twitter.com/1/statuses/user_timeline.rss?include_entities=false&include_rts=true&count="+ str(Count) +"&screen_name=" + user ) | |
file_listuser.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment