I've been having issues getting passed this bug, I was wondering If anyone could help. Or could point me in the right direction? I believe the issue may be with API.get_user. But I just cannot find a workaround it.
This script is supposed to read a csv file of Twitter usernames(list.csv) and pull the unique IDs. Then format those IDs into another csv file.(ids.csv)
here is the error I receive when running get_user_ids.py these lines end up populating in my newly generated ids.csv file.
get_user() takes 1 positional argument but 2 were given
import tweepy
import time
import csv
import sys
consumer_key = "CONSUMER_KEY"
consumer_secret = "CONSUMER_SECRET"
access_token = "ACCESS_TOKEN"
access_token_secret = "ACCESS_TOKEN_SECRET"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
def get_user_ids():
handles = []
with open("list.csv", "r") as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in reader:
for elem in row:
handles.extend(elem.strip().split(','))
for handle in handles:
try:
u = api.get_user(handle[1:-1])
time.sleep(6)
print (u._json['id'])
sys.stderr.write(str(u._json['id']) + "\n")
except Exception as e:
print (e)
if __name__ == '__main__':
get_user_ids()