- # pyex7_selenium_webadvisor.py - Interact with webadvisor course search
- from selenium import webdriver
- from selenium.webdriver.support.ui import Select # for dropdown menus
- from selenium.webdriver.chrome.options import Options # for "headless" Chrome
- import time # implement pauses
- # Instance of Options class to configure headless Chrome
- options = Options()
- # Parameter to tell Chrome that it should run without UI (headless)
- options.headless = True
- driver = webdriver.Chrome(options=options)
- driver.get('https://www2.monmouth.edu/muwebav/wa3/search/SearchClassesv2.aspx')
- # Select the term
- term_val = '23/SU'
- # Find the Term dropdown menu
- term_select = Select(driver.find_element_by_name('_ct10:MainContent:ddlTerm'))
- term_select.select_by_value(term_val)
- # Select the subject
- subj_val = 'CS'
- # Find the Subject dropdown menu
- subj_select = Select(driver.find_element_by_name('_ct10:MainContent:ddlSubj_1'))
- subj_select.select_by_value(subj_val)
- # Click the Submit button
- driver.find_element_by_name('_ct10:MainContent:btnSubmit').click()
- # Get resulting html and print it
- print(driver.page_source)
- # Close the browser window
- driver.quit
[text] exercise 7 - selenium
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: