Hey,
So I am getting the following error when trying to run my code...
Traceback (most recent call last):
File "follow_users_followers.py", line 30, in <module>
retweeters = twitter.get_retweeters_ids(id = k)
File "/home/graingerkid/.local/lib/python2.7/site-packages/twython/endpoints.py", line 125, in get_retweeters_ids
return self.get('statuses/retweeters/ids', params=params)
File "/home/graingerkid/.local/lib/python2.7/site-packages/twython/api.py", line 230, in get
return self.request(endpoint, params=params, version=version)
File "/home/graingerkid/.local/lib/python2.7/site-packages/twython/api.py", line 224, in request
content = self._request(url, method=method, params=params, api_call=url)
File "/home/graingerkid/.local/lib/python2.7/site-packages/twython/api.py", line 145, in _request
raise TwythonError(str(e))
twython.exceptions.TwythonError: Cannot connect to proxy. Socket error: [Errno 111] Connection refused.
Can anyone point me in the right direction to fix this, it is actually making the first call successfully but it then fails on the second.
Here is my code...
from twython import Twython # pip install twython
import time
import csv
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_KEY = ''
ACCESS_SECRET = ''
twitter = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
api_calls = 0
user_timeline = twitter.get_user_timeline(screen_name="", count=200, include_retweets=False)
api_calls = api_calls +1
dic = {}
for tweet in user_timeline:
dic[tweet['id_str']] = tweet['retweet_count']
retweeter_handles = []
for k, v in dic.iteritems():
if v > 0:
retweeters = twitter.get_retweeters_ids(id = k)
api_calls = api_calls +1
for i in retweeters['ids']:
retweeter_handles.extend(retweeters['ids'])
#print retweeters['ids']
time.sleep(150)
output = twitter.lookup_user(user_id=retweeter_handles[0:100])
username_list=[]
#Loop through the results
for user in output:
username_list.append(user['screen_name'])
with open("output.csv", "wb") as f:
for user in username_list:
writer = csv.writer(f)
writer.writerows(user)
FYI this runs perfect off my desktop
Thanks in advance
[edit by admin: formatting]