I am trying to get all the search results from a search by name on Twitter.
Can anyone help me how can I use tweepy to list all the users, bio, # of followers for all of the search results from a search by name in Python
parse_list
is a list containing all the usernames(more specifically screen names), and you can get their information and/or records by coding something like this:
for sname in parse_list:
try:
user_tweets = api.user_timeline(screen_name = sname, tweet_mode = 'extended', lang='en', count=100, include_rts=True)
except tweepy.error.TweepError:
print("Failed to run the command on that user, Skipping...")
continue
# user_tweets = tweepy.Cursor(api.user_timeline, screen_name=sname, tweet_mode = 'extended', lang='en').items(20)
print(str(count)+" "+sname)
for t in user_tweets:
if hasattr(t, 'retweeted_status'):
author = t.retweeted_status.user.screen_name
else: author = t.user.screen_name
user_id = t.user.id
user_name = t.user.name
user_screenName = t.user.screen_name
user_text = t.full_text
#user_text = re.sub(r"http\S+", "", user_text)
user_text = re.sub(r'https?:\/\/.*[\r\n]*', '', user_text, flags=re.MULTILINE)
user_text.replace("\n"," ").replace("\r"," ").replace("|"," ").replace(" | "," ").replace("?"," ")
user_text = ' '.join(user_text.split())
user_timestamp = t.created_at
user_retweet = t.retweet_count
user_favorite = t.favorite_count
userframe = [user_id,user_name,user_screenName, author,user_text,user_timestamp,user_retweet,user_favorite]
mega_tweet_list.append(userframe)
Here all the Bio you might be looking for is stored in userframe
. If you require more/other datapoints, please consider searching "twitter Introduction to JSON object" on google and you should find types of information points of your interest.