Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Python program that checks Nike's tweets every N seconds looking for a specified string
- from twitter import *
- import time
- import msvcrt
- ACCESS_TOKEN = "2784389341-wqC1Tck0nMU16VMtRn9UQwGh1jOXsKC0p5vQdIZ"
- ACCESS_TOKEN_SECRET = "pYc3kXRjrREVlTwkHhCaSynKqC91fskfTsKmH5GfB61MA"
- CONSUMER_KEY = "MtiQ2xbUIcG5gFu3gfUrsgsxa"
- CONSUMER_SECRET = "S8VeGHCF0EGRVHFwo42zU57Nz1gIbuQuphV7lnXIqZfPHHDQLH"
- t = Twitter(auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET))
- search_string = input("Enter a search string: ")
- search_interval = input("Enter search interval(seconds)")
- def checkTweets(name):
- #while("User has not exited program")
- #Checks Nike's last 5 tweets every 30 seconds
- try:
- while True:
- tweets = t.statuses.user_timeline(screen_name="nike", count=1, exclude_replies=True)
- tweets = str(tweets)
- if name in tweets:
- print("Found Match!")
- print(tweets)
- #Add code to extract URL from tweet
- #Add code to open browser on user's computer
- #Add code to navigate browser to given URL
- break
- else:
- print("Sorry, no match found! Retrying in 5 seconds")
- time.sleep(int(search_interval))
- continue
- except KeyboardInterrupt:
- pass
- checkTweets(search_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement