python - Get location specific tweets from Twitter using Tweepy -


i'm trying tweets specific location using tweepy error when run code

raise tweeperror("wrong number of locations points, " tweepy.error.tweeperror: wrong number of locations points, has multiple of 4 

in code, try tweets new york city location coordinates ny. how can tweets ny alone? guess use range of coordinates between x,y , y,z. how go this?

here code:

class stdoutlistener(streamlistener):     """ listener handles tweets received stream.     basic listener prints received tweets stdout.     """     def on_data(self, data):         try:             print(data)             savefile = open('newtweets.csv', 'a')             savefile.write(data)             savefile.write('/n').encode("utf-8")             savefile.close()             return true         except baseexception:             print ('failed ondata')             time.sleep(5)      def on_error(self, status):         print(status.encode("utf-8"))  if __name__ == '__main__':     l = stdoutlistener()     auth = oauthhandler(consumer_key, consumer_secret)     auth.set_access_token(access_token, access_token_secret)     #ask keyword collect data     user_keyword=input("what keyword want mine?")     stream = stream(auth, l)     stream.filter(locations=[40.7127,74.0059], track=[user_keyword]) 

it needs 4 coordinates. nyc, example:

stream.filter(locations=[-74.1687,40.5722,-73.8062,40.9467])

here's first google result of site let's draw bounding boxes. select csv format on bottom-left of page.

it's important note, mentioned in post, cannot filter both location , keyword.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -