Skip to content

Instantly share code, notes, and snippets.

@hyperobject
Last active August 29, 2015 14:19
Show Gist options
  • Save hyperobject/9024377a3af6e1b5ef79 to your computer and use it in GitHub Desktop.
Save hyperobject/9024377a3af6e1b5ef79 to your computer and use it in GitHub Desktop.
Scratch + twitter
"""
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
@MegaApuTurkUltra
Copy link

Python makes this like 10 lines :P

Good job! (You earned my star)

@hyperobject
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment