SHARE
TWEET

python selenium scrape apps.upenn.edu

furas Feb 25th, 2020 (edited) 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import selenium.webdriver
  2.        
  3. def scrape(last_name, first_name):        
  4.     url = 'https://directory.apps.upenn.edu/directory/jsp/fast.do'
  5.    
  6.     driver = selenium.webdriver.Firefox()
  7.     driver.get(url)
  8.    
  9.     inputs = driver.find_elements_by_tag_name('input')
  10.  
  11.     #for item in inputs:
  12.     #    print(item.get_attribute('name'))
  13.              
  14.     inputs[2].send_keys(last_name)
  15.     inputs[3].send_keys(first_name)
  16.    
  17.     driver.find_element_by_class_name('submitButton').click()
  18.  
  19.     items = driver.find_elements_by_xpath('//tr[@class="lookupbody"]//a[@class="linkText"]')
  20.     for item in items:
  21.         print(item.text)
  22.  
  23. # --- main ---
  24.  
  25. scrape("Tomasco", "Lauretta")
  26. #scrape("Austin", "Westberg")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top