Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I want to collect tweets from twitter on a specific topic at specific geographic regions. I did Road traffic in New York City. But i
I want to collect tweets from twitter on a specific topic at specific geographic regions. I did Road traffic in New York City. But i do not why it doesn't have results.
import tweepy consumer_key = 'ip., Consumer_secret = '. access_token_key = ', access_token_secret = 'E'On. ' . AfAun--II auth = tweepy. OAuthHandler(consumer_key, consumer_secret), auth.set_access_token (access_token_key, access_token_secret) myApi = tweepy.API (auth) def rest_query_ex1(): geo = '40.730610, -73.935242, 1mi' tweets = myApi. search(g="iphone", geocode-geo), for tweet in tweets: print tweet.created_at, tweet.user.screen_name, tweet.text def rest_query_ex20: query = 'traffic OR stuck' tweets = myApi. search(q-query), for tweet in tweets: print tweet.created.at, tweet.screen.name, tweet. text def rest_query_ex3): query = 'traffic OR stuck' geo = '40.730610, -73.93524, 1mi' MAX_ID = None tweets = myApi. search (g=query, geocode=geo, Count=100, max_id MAX_ID) for it in range(2) : tweets = myApi. search(g=query, geocode-geo, Count=100, max_id=MAX_ID), if tweets: MAX_ID = tweets [-1].id print MAX_ID, len (tweets) print tweets [-1].text import tweepy consumer_key = 'ip., Consumer_secret = '. access_token_key = ', access_token_secret = 'E'On. ' . AfAun--II auth = tweepy. OAuthHandler(consumer_key, consumer_secret), auth.set_access_token (access_token_key, access_token_secret) myApi = tweepy.API (auth) def rest_query_ex1(): geo = '40.730610, -73.935242, 1mi' tweets = myApi. search(g="iphone", geocode-geo), for tweet in tweets: print tweet.created_at, tweet.user.screen_name, tweet.text def rest_query_ex20: query = 'traffic OR stuck' tweets = myApi. search(q-query), for tweet in tweets: print tweet.created.at, tweet.screen.name, tweet. text def rest_query_ex3): query = 'traffic OR stuck' geo = '40.730610, -73.93524, 1mi' MAX_ID = None tweets = myApi. search (g=query, geocode=geo, Count=100, max_id MAX_ID) for it in range(2) : tweets = myApi. search(g=query, geocode-geo, Count=100, max_id=MAX_ID), if tweets: MAX_ID = tweets [-1].id print MAX_ID, len (tweets) print tweets [-1].textStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started