-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_api.py
53 lines (41 loc) · 1.31 KB
/
check_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
from datetime import datetime,timedelta
from dateutil.parser import parse
import time
local=datetime.now()
tweets_data_path = 'data.txt'
class User(object):
name=""
urls=[]
def display(self):
print self.name
print self.link
while(True):
tweets_file = open(tweets_data_path, "r")
users=[]
for line in tweets_file:
try:
tweet = json.loads(line)
user=User()
created_at=parse(tweet["created_at"])
created_at=created_at.strftime("%Y-%m-%d %H:%M:%S")
created_at=parse(created_at)
created_at=created_at +timedelta(hours=5,minutes=30)
if((abs(local-created_at).total_seconds())/60 > 5):
local=datetime.now()
else:
user.name=tweet["user"]["name"]
for url in tweet["entities"]['urls']:
user.urls.append( url['expanded_url'])
users.append(user)
except:
continue
for user in users:
print "User Name :" + user.name
for url in user.urls:
print url
print "Total Urls Related :%d" %(len(user.urls))
print "****************"
print "------------------------------------------------------------"
tweets_file.close()
time.sleep(60)