Created
August 18, 2017 21:08
-
-
Save prail/e9ec58723c60da32bfe25ad2f39e9d34 to your computer and use it in GitHub Desktop.
A broken commenter for scratch.mit.edu.
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
#Write all of this in PHP so I can run it on 000webhost | |
import requests | |
import json | |
import warnings | |
warnings.filterwarnings("ignore") | |
USERNAME="mit" | |
PASSWORD="romney" | |
USERPAGE="kimjongun" | |
s=requests.Session() | |
HEADERS={ | |
"X-Requested-With": "XMLHttpRequest", | |
"Referer":"https://scratch.mit.edu/" | |
} | |
s.get("https://scratch.mit.edu/csrf_token/",headers=HEADERS,verify=False) | |
CSRF_TOKEN=s.cookies.get("scratchcsrftoken") | |
HEADERS["X-CSRFToken"]=CSRF_TOKEN | |
data={ | |
"username": USERNAME, | |
"password": PASSWORD, | |
"embed_captcha": True, | |
"timezone": "America/Los_Angeles", | |
"csrfmiddlewaretoken": CSRF_TOKEN | |
} | |
login=s.post("https://scratch.mit.edu/login/",json=data,headers=HEADERS,verify=False) | |
if login.status_code == 200: | |
#PROFILE=json.loads(requests.get("https://api.scratch.mit.edu/users/{}".format(USERNAME),verify=False).content.decode()) | |
data={ | |
"content":"Cow says moo.", #THIS TOO | |
"parent_id": '', #THIS NEEDS TO BE CHANGED | |
"commentee_id": '', | |
} | |
# vvv This needs changing. | |
HEADERS["Referer"]="https://scratch.mit.edu/users/{}".format(USERPAGE) | |
req=s.post("https://scratch.mit.edu/site-api/comments/user/{}/add/".format("TheUltimatum"),json=data,headers=HEADERS,verify=False) | |
print(req.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|o| wut