Skip to content

Instantly share code, notes, and snippets.

@max-kov
Created July 16, 2017 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save max-kov/82a90a0c3ddce2674089327433394482 to your computer and use it in GitHub Desktop.
Save max-kov/82a90a0c3ddce2674089327433394482 to your computer and use it in GitHub Desktop.
dr frost maths python point farmer
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)
@TheGodOfNoodles
Copy link

i download the python file then?

@felix055
Copy link

felix055 commented Feb 5, 2021

<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