def __init__(self, username: str, password: str):
"""
This method sets up scraper, and logs in to Its Learning. It enables the other methods to scrap
content, like calendar feed, exercises and course list.
:param username: FEIDE-username
:param password: FEIDE-password
"""
self.username = username
self.password = password
# Initializes the correct version of chromedriver with regards to OS
driver_directory = os.path.dirname(__file__)
if platform.system() == "Windows":
relative_path = "chromedriver.exe"
else:
relative_path = "chromedriver"
absolute_file_path = os.path.join(driver_directory, relative_path)
chrome_profile = webdriver.ChromeOptions()
self.driver = webdriver.Chrome(executable_path=absolute_file_path)
self.driver.get("http://www.ilearn.sexy") # Shortcut to itslearning
# logs into Its Learning. After this the "driver" contains the main page in Its Learning
username_field = self.driver.find_element_by_name("feidename")
username_field.send_keys(username)
password_field = self.driver.find_element_by_name("password")
password_field.send_keys(password)
password_field.submit()
评论列表
文章目录