Pergunta

Hello everyone I am trying to do a research project where I am trying to pull all twitter user profiles (or at least some subset number of users of them).

From pulling this data, I want to store in a file all users whose bios or description field has certain word or words in them.

here is my code that I have come up with and been trying to work with:

import tweepy
import csv

ckey ='...'
csecret ='...'
atoken = '...'
asecret = '...'

# Attributes of a twitter user profile (this header is already on my file)
twitter_datafile_attr = ['follow_request_sent', 'profile_use_background_image',       'contributors_enabled', 'id', 'verified', 
                       'profile_image_url_https', 'profile_sidebar_fill_color', 'profile_text_color', 'followers_count', 
                       'profile_sidebar_border_color', 'id_str', 'default_profile_image', 'listed_count' 'is_translation_enabled', 
                       'utc_offset', 'statuses_count', 'description', 'friends_count', 'location', 'profile_link_color', 
                       'profile_image_url', 'notifications', 'geo_enabled', 'profile_background_color', 'profile_banner_url', 
                       'profile_background_image_url', 
                       'screen_name', 'lang', 'following', 'profile_background_tile', 'favourites_count', 'name', 'url', 'created_at', 
                       'profile_background_image_url_https', 'time_zone', 'protected', 'default_profile', 'is_translator']

#Authencation
auth = tweepy.OAuthHandler(ckey,csecret)
auth.set_access_token(atoken,asecret)
api=tweepy.API(auth)
# search for people who have both the words "hawaii and "water" anywhere in their bios
user=api.search('hawaii water')

Here is where I am stuck, I have tried to use get_user(ctr) where ctr iterates up to a certain number of users by twitter id. Processing the data to a csv file is easy I have already implemented the code for it.

Should I just do a manual search on twitter.com and view the sourcecode file and parse the data with regular expressions or is there another way using tweepy to get user profiles matching certain words in their bios?

Any help would be appreciated. Thanks

Foi útil?

Solução

I was able to find out on my own.

you use api.search_users(query) to search for usernames matching a certain query.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top