Last active
August 29, 2015 14:19
-
-
Save hyperobject/9024377a3af6e1b5ef79 to your computer and use it in GitHub Desktop.
Scratch + twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
pip install python-twitter | |
pip install requests | |
pip install bs4 | |
""" | |
import twitter | |
import requests | |
from bs4 import BeautifulSoup as soup | |
import time | |
api = twitter.Api(consumer_key='consumerkey', | |
consumer_secret='consumersecret', | |
access_token_key='accesstoken', | |
access_token_secret='accesssecret') #get these from apps.twitter.com | |
old = "" | |
user = "technoboy10" #change this to your username | |
while True: | |
r = requests.get('https://scratch.mit.edu/messages/ajax/user-activity/?user=' + user + '&max=20').text | |
s = soup(r) | |
url = 'http://scratch.mit.edu' + s.div.a["href"] | |
activity = ' '.join(s.div.text.split()[:-3]) + " " + url | |
if not activity == old: | |
old = activity | |
print activity | |
api.PostUpdate(activity) | |
time.sleep(300) #so that Scratch doesn't get super spammed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python makes this like 10 lines :P
Good job! (You earned my star)