0

I am using this code suggested by alecxe in order to collect the followers' ids for every user I have in a dictionary. This is the code I am using:

networkFile = open(r"xxxxx/network%s.txt"% timestr, "w")
for key, value in accounts_alive_dic.iteritems():
    print ("main: "+key)
    ids = []
    for page in tweepy.Cursor(api.followers_ids, screen_name=accounts_alive_dic[key][0]).pages():
        try:
            ids.extend(page)
            time.sleep(60)
            print(ids)
        except:
            ids=[]
            print("Second loop exception for key "+key)
    for id in ids:
        try:
            print(key+","+str(id)+'\n')
            networkFile.write(key+","+str(id)+'\n')
        except:
            print("Third loop exception for key "+key)

networkFile.close()

Unfortunately, after several followers' ids have been collected I get this error message:

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "/usr/lib/python2.7/site-packages/tweepy/cursor.py", line 75, in next
    **self.kargs)
  File "/usr/lib/python2.7/site-packages/tweepy/binder.py", line 239, in _call
    return method.execute()
  File "/usr/lib/python2.7/site-packages/tweepy/binder.py", line 223, in execute
    raise TweepError(error_msg, resp)
TweepError: [{u'message': u'Sorry, that page does not exist.', u'code': 34}]

Do you have any ideas on what is causing this error and how can I fix the problem? Many thanks.

Community
  • 1
  • 1
helium
  • 260
  • 3
  • 11

1 Answers1

0

Fixed. The problem was that some users have dynamic usernames(pretty smart uh?!). I solved the problem by using the user id instead of the username. So now this line from my previous code:

for page in tweepy.Cursor(api.followers_ids,screen_name=accounts_alive_dic[key][0]).pages()

looks like:

for page in tweepy.Cursor(api.followers_ids, id=key).pages()

Hope this can help someone out there.

helium
  • 260
  • 3
  • 11