Created
July 16, 2017 18:13
-
-
Save max-kov/82a90a0c3ddce2674089327433394482 to your computer and use it in GitHub Desktop.
dr frost maths python point farmer
This file contains hidden or 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
import requests | |
from BeautifulSoup import BeautifulSoup | |
import dryscrape | |
import time | |
url = "http://www.drfrostmaths.com/homework/do-question.php?aaid=161230" | |
sess = dryscrape.Session() | |
sess.visit("http://www.drfrostmaths.com/homework/login.php") | |
name = sess.at_xpath('//*[@name="login-email"]') # Where <input name="username"> | |
name.set("email here") | |
password = sess.at_xpath('//*[@name="login-password"]') # Where <input name="password"> | |
password.set("passwd here") | |
# Push the button | |
name.form().submit() | |
while 1: | |
sess.visit(url) | |
time.sleep(1) | |
response = sess.body() | |
soup = BeautifulSoup(response) | |
question = soup.find("script", {"id": "MathJax-Element-1"}).text.encode('utf-8') | |
try: | |
question = question.replace("\\times","*") | |
ans = eval(question) | |
ans_form = sess.at_xpath('//*[@name="numeric-answer-1"]') | |
ans_form.set(ans) | |
print(question) | |
except: | |
button = sess.at_xpath('//*[@id="ma1"]') | |
if button !=None: | |
button.click() | |
for x in range(10): | |
ans_form = sess.at_xpath('//*[@name="numeric-answer-'+str(x)+'"]') | |
if ans_form!=None: | |
ans_form.set(1) | |
print "bad question" | |
sess.at_xpath('//*[@type="submit"]').click() | |
time.sleep(2) |
how do i use it?
i download the python file then?
<script src="https://gist.github.com/max-kov/82a90a0c3ddce2674089327433394482.js"></script>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, how do I get added to the discord?... It doesn't work for me either... sorry I know you aren't replying @ak16...., but if you see this pls help, I have to beat the other people in my class lol.