Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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].text

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is human nature?

Answered: 1 week ago