Update lab1.md

master
Vladimir Protsenko 3 years ago
parent 1b44ec980f
commit 363a714aec

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

Loading…
Cancel
Save