bcit.py 673 B

123456789101112131415161718192021
  1. import time
  2. import re
  3. from selenium import webdriver
  4. from bs4 import BeautifulSoup
  5. DRIVER_PATH = "/Users/michaeltang/.wdm/drivers/chromedriver/88.0.4324.96/mac64/chromedriver"
  6. URL = "https://www.bcit.ca/"
  7. # This loads webdriver from the local machine if it exists.
  8. browser = webdriver.Chrome(DRIVER_PATH)
  9. browser.get(URL)
  10. # Give the browser time to load all content.
  11. time.sleep(4)
  12. search = browser.find_element_by_css_selector("#site-header-search")
  13. search.send_keys("Analytics")
  14. # Find the search button - this is only enabled when a search query is entered
  15. button = browser.find_element_by_css_selector(".site-header__search-btn")
  16. button.click() # Click the button