Skip to content

Instantly share code, notes, and snippets.

@johanndiedrick
Last active June 7, 2020 03:38
Show Gist options
  • Save johanndiedrick/a565b57630925c60904e2659f9a8798f to your computer and use it in GitHub Desktop.
Save johanndiedrick/a565b57630925c60904e2659f9a8798f to your computer and use it in GitHub Desktop.
import requests
import tweepy
import json
from datetime import timezone, timedelta
import datetime
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
response = requests.get('https://scanmap.frnsys.com/NY/log')
json_data = json.loads(response.text)
# Getting the current date
# and time
dt = datetime.datetime.utcnow() - datetime.timedelta(minutes=26)
utc_time = dt.replace(tzinfo = timezone.utc)
utc_timestamp = utc_time.timestamp()
#print(type(utc_timestamp))
#for x in json_data['logs']:
# print(x)
print(len(json_data['logs']))
latest_logs = [x for x in json_data['logs'] if float(x['timestamp']) > utc_timestamp]
print(len(latest_logs))
for x in latest_logs:
api.update_status('LOCATION: ' + x['data']['location'] + ' | MESSAGE: ' + x['data']['text']) "192.168.1.2" 21:17 06-Jun-20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment