-1

I want a script code to collecting random tweet from Chicago without any keyword that every 30 min run automatically and collect tweet for 20 millisecond (for example) All Available codes need keywords and in most of them I can't define geographic location. Thanks for your helps.

SAAM1994
  • 11
  • 1

2 Answers2

0

See these pages : An Introduction to Text Mining using Twitter Streaming API and Python and this page too run a python script every hour

Sayok Majumder
  • 1,012
  • 13
  • 28
0

This is very doable. With Twitter's REST API a keyword is required; however, Twitter also provides a Streaming API which can use either a keyword or a location to filter tweets. In your case, you would need to define the bounding box of of Chicago in longitudes and latitudes. Then supply this to Twitter's statuses/filter endpoint documented here: https://developer.twitter.com/en/docs/tweets/filter-realtime/api-reference/post-statuses-filter.html. This endpoint has a locations parameter that you would use. It returns tweets as they are posted. No timer required.

You can use tweepy for this. Or, with TwitterAPI you would simply do something like this:

from TwitterAPI import TwitterAPI
api =  TwitterAPI(CONSUMERKEY,CONSUMERSECRET,ACCESSTOKENKEY,ACCESSTOKENSECRET)
r = api.request('statuses/filter', {'locations':'-87.9,41.6,-87.5,42.0'})
for item in r:
        print(item)
Jonas
  • 3,969
  • 2
  • 25
  • 30