-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetTweeterFollowers.py
51 lines (40 loc) · 1.4 KB
/
GetTweeterFollowers.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
import csv
from pymongo import MongoClient
from twython import Twython
import os.path
import time
import subprocess
consumer_key = "Sk086O2NyEiL51b7kOA1Vur8s"
consumer_secret = "yTZND3JPdGFCQQMF8TPwU0yOS5wiF47XNl2jXUGTCbM3y5Bq1S"
access_token = "243047872-BGdWwZDS4aTxsAXzDWPbuHsd1J0Pus3gmrb55Ift"
access_token_secret = "KYVRB8FvkzZjpDxGyk08oFgRu7ElNMqP7DUfnU8BqLOGo"
twitter = Twython(consumer_key,consumer_secret,access_token,access_token_secret)
followers = {}
followersFile = '/californiaShootingTweets/followers.json'
tweetersFile = '/californiaShootingTweets/UniqueTweeters.txt'
filePath='/californiaShootingTweets/'
with open(followersFile, 'r') as f:
for line in f:
if line != "":
json_acceptable_string = line.replace("'", "\"")
follow = json.loads(json_acceptable_string)
keys=follow.keys()
for key in keys:
followers[key]=follow[key]
tweeters = []
with open(tweetersFile,'r') as f:
for line in f:
if line != " ":
tweeter=line.rstrip()
tweeters.append(tweeter)
for tweeter in tweeters:
fileName=filePath+tweeter+'_FOLLOWERS.txt'
if os.path.isfile(fileName):
pass
else:
try:
subcommand='../influence_measure/virtual/bin/python twythonSample.py '+tweeter
p=subprocess.call(['../influence_measure/virtual/bin/python','twythonSample.py',tweeter])
except Exception as e:
pass