Guest User

Untitled

a guest
Jan 9th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. for month in (month_start, month_end):
  2.  
  3. for date in (date_start, date_end):
  4.  
  5. try: #this is just a general try in case there is a breakdown in finding one of the elements
  6. driver.get(url)
  7. results = driver.find_elements_by_xpath("""//*[@class="results"]/div""")
  8.  
  9. for result in results:
  10. sample_element = result.find_element_by_xpath("blah").text
  11.  
  12. #seems to be where the problem starts
  13. specific_element = ""
  14. try:
  15. #this is a specific element that I know may not exist
  16. specific_element = result.find_element_by_xpath(""".//*[@class="specific"]/div""").text
  17. except NoSuchElementException:
  18. specific_element = ""
  19. #I have tried pass instead as well with no luck
  20. #throws an error here and won't continue if the specific element is not found
  21. except:
  22. #pretty much a copy of the above try with some changes
Add Comment
Please, Sign In to add comment