![]() ![]() Tweet text: RT Media Bulletin on status of positive cases #COVID19 in Telangana. # will give you the general location of the user and not the particular location for the tweet itself, as it turns out, most of the users do not share the exact location of the tweet Print("created_at: ".įormat(tweet.created_at, _name, tweet.text, )) # the geocode is for India format for geocode="lattitude,longitude,radius" ![]() Tweets = tweepy.Cursor(api.search, =search_words, Import credentials # all my twitter API credentials are in this file, this should be in the same directory as is this scriptĪuth = tweepy.OAuthHandler(nsumer_key,Īuth.set_access_secret(credentials.access_token,Īpi = tweepy.API(auth, wait_on_rate_limit=True) # set wait_on_rate_limit =True as twitter may block you from querying if it finds you exceeding some limits I am working on extracting twitter data for around a location (in here, around India), for all tweets which include a special keyword or a list of keywords. Twstalker, Search twitter profiles and analyze trending topic hashtags. # to keep things simple, we will give up on an error # depending on de, one may want to retry or wait New_tweets = api.search(q=query, count=count, max_id=str(last_id - 1)) Update: in response to Andre Petre's comment about potential memory consumption issues with tweepy.Cursor, I'll include my original solution, replacing the single statement list comprehension used above to compute searched_tweets with the following: searched_tweets = Ĭount = max_tweets - len(searched_tweets) # assuming twitter_authentication.py contains each of the 4 oauth elements (1 per line)įrom twitter_authentication import API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRETĪuth = tweepy.OAuthHandler(API_KEY, API_SECRET)Īuth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) The following code fetches the most recent 1000 mentions of 'python'. However, I discovered there is a far simpler way to solve the problem using a tweepy.Cursor (see tweepy Cursor tutorial for more on using Cursor). I originally worked out a solution based on Yuva Raj's suggestion to use additional parameters in GET search/tweets - the max_id parameter in conjunction with the id of the last tweet returned in each iteration of a loop that also checks for the occurrence of a TweepError. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |