Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Sun May 28 21:26:50 2017
- @author: Pranavtadepalli and houd163
- """
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.support.wait import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- import time
- from bs4 import BeautifulSoup as soup
- from bs4 import SoupStrainer
- from selenium.webdriver.common.action_chains import ActionChains
- import getpass
- #ui = input('What is your IXL username?\n\n')
- #pi = getpass.getpass('\nWhat is your IXL password?\n\n')
- ui = 'myusername'
- pi = 'mypass'
- driver = "C:\\Users\\agzsc\\Documents\\Python Projects\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe"
- driver = webdriver.PhantomJS(driver)
- driver.get('https://www.ixl.com')
- username = driver.find_element_by_id('qlusername')
- password = driver.find_element_by_id('qlpassword')
- submit = driver.find_element_by_id('qlsubmit')
- print('Logging in')
- username.send_keys(ui)
- password.send_keys(pi)
- ActionChains(driver).move_to_element(submit).click().perform()
- smartscore = 0
- x = -1
- while smartscore<91:
- source = soup(driver.page_source, 'lxml')
- x = x + 1
- time.sleep(1)
- driver.execute_script('''window.open('https://www.ixl.com/math/grade-3/multiply-by-11','_blank');''')
- driver.switch_to_window(driver.window_handles[1+x])
- time.sleep(5)
- print('Getting question')
- problem = source.find('div', class_='math').get_text()
- problem = problem.split(':')[1]
- problem = problem.replace("×", "*")
- problem = problem.replace(" ", "")
- problem = problem.replace("=", "")
- problem = problem.replace(" ", "")
- solution = eval(problem)
- print('The solution is: ' + str(solution))
- print('Submitting answer')
- driver.find_element_by_class_name('fillIn').send_keys(solution)
- try:
- submit = driver.find_elements_by_xpath("//button[contains(text(), 'Submit')]")[1]
- except:
- submit = driver.find_elements_by_xpath("//button[contains(text(), 'Submit')]")[0]
- ActionChains(driver).move_to_element(submit).click().perform()
- smartscore = driver.find_element(by=By.ID, value='currentscore')
- smartscore = int(smartscore.text)
- print("The smartscore is: " + str(smartscore))
- print('The IXL is complete!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement