Tutorial

For Interesting


Python to browse

Preparation:

- Python 3.6.5
- Chrome version 76
- Chrome Driver version 76


1 Install Python (Skippable)



2 Place Chrome Driver folder to [C:]



3 Command Line Interface



4 Sample Code

(VTC Myportal Timetable) [.py]

import time
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")
driver.get('https://myportal.vtc.edu.hk')
cna = /* Your Student Number */
pw = /* Your Password */
line1 = driver.find_element_by_name('userid')
line1.click()
time.sleep(0.1)
line1.send_keys(cna)
time.sleep(0.1)
line2 = driver.find_element_by_name('password')
line2.click()
time.sleep(0.1)
line2.send_keys(pw)
time.sleep(0.5)
submit = driver.find_element_by_id('submitBtn')
submit.click()
time.sleep(1)
timetable = driver.find_element_by_link_text('Timetable')
timetable.click()
	

5 Uninstall latest version Chrome



6 Install version 76 Chrome



7 Change [.py] properties



8 Perform the code!


Reference