|
|
@ -148,6 +148,7 @@ API_KEY = "YOUR_API_KEY"
|
|
|
|
API_SECRET = "YOUR_API_SECRET"
|
|
|
|
API_SECRET = "YOUR_API_SECRET"
|
|
|
|
ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
|
|
|
|
ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
|
|
|
|
ACCESS_TOKEN_SECRET = "YOUR_ACCESS_TOKEN_SECRET"
|
|
|
|
ACCESS_TOKEN_SECRET = "YOUR_ACCESS_TOKEN_SECRET"
|
|
|
|
|
|
|
|
GEOBOX_SAMARA_BIG = [48.9700523344,52.7652295668,50.7251182524,53.6648329274]
|
|
|
|
|
|
|
|
|
|
|
|
class MyStreamListener(tweepy.StreamListener):
|
|
|
|
class MyStreamListener(tweepy.StreamListener):
|
|
|
|
def on_status(self, status):
|
|
|
|
def on_status(self, status):
|
|
|
@ -168,23 +169,21 @@ class MyStreamListener(tweepy.StreamListener):
|
|
|
|
if status_code == 420:
|
|
|
|
if status_code == 420:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def monitoring_samara_tweets(api, query=""):
|
|
|
|
def monitoring_samara_tweets(api, query="", locations=None):
|
|
|
|
GEOBOX_SAMARA_BIG = [48.9700523344,52.7652295668,50.7251182524,53.6648329274]
|
|
|
|
|
|
|
|
myStreamListener = MyStreamListener()
|
|
|
|
myStreamListener = MyStreamListener()
|
|
|
|
myStream = tweepy.Stream(
|
|
|
|
myStream = tweepy.Stream(
|
|
|
|
auth = api.auth,
|
|
|
|
auth = api.auth,
|
|
|
|
listener=myStreamListener
|
|
|
|
listener=myStreamListener
|
|
|
|
)
|
|
|
|
)
|
|
|
|
myStream.filter(locations=GEOBOX_SAMARA_BIG)
|
|
|
|
myStream.filter(track=[query], locations=locations)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
query = [" "]
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
|
|
|
|
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
|
|
|
|
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
|
|
|
|
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
|
|
|
|
api = tweepy.API(auth)
|
|
|
|
api = tweepy.API(auth)
|
|
|
|
monitoring_samara_tweets(api, query)
|
|
|
|
monitoring_samara_tweets(api, query="", locations=GEOBOX_SAMARA_BIG)
|
|
|
|
except Exception as error_msg:
|
|
|
|
except Exception as error_msg:
|
|
|
|
print (error_msg)
|
|
|
|
print (error_msg)
|
|
|
|
```
|
|
|
|
```
|
|
|
|