Guest User

Script

a guest
Aug 17th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. from selenium import webdriver
  3. from selenium.webdriver import Chrome
  4. from selenium.webdriver.chrome.service import Service
  5. from selenium.webdriver.chrome.options import Options
  6. from selenium.webdriver.common.action_chains import ActionChains
  7. from selenium.webdriver.common.by import By
  8. from selenium.webdriver.support.wait import WebDriverWait
  9. from selenium.webdriver.support import expected_conditions as EC
  10. from selenium.common.exceptions import *
  11.  
  12.  
  13. ##Chrome Options#
  14. serv = Service("<PATH>")
  15. opts = Options()
  16. opts.headless = False
  17. opts.add_argument("--start-maximized")
  18. opts.binary_location = "<PATH>
  19. driver = Chrome(service=serv, options=opts)
  20. driver.get('https://www.connectcre.com/chicago-midwest/')
  21. innerHTML = driver.execute_script("return document.body.innerHTML")
  22. soup = BeautifulSoup(innerHTML, "lxml")
  23.  
  24.  
  25. element = driver.find_element(By.CSS_SELECTOR, ("div[id='ajax-load-more-2'] button[type='button']"));
  26. driver.execute_script("return arguments[0].scrollIntoView();", element);
  27. innerHTML = driver.execute_script("return document.body.innerHTML")
  28. print("Success")
  29. print(soup)
  30. botton_to_click = WebDriverWait(driver, 45).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ("div[id='ajax-load-more-2'] button[type='button']"))))
  31. innerHTML = driver.execute_script("return document.body.innerHTML")
  32. botton_to_click.click()
  33. print("click")
  34. botton_to_click.click()
  35. print("click 2")
  36.  
  37. driver.close
  38.  
Advertisement
Add Comment
Please, Sign In to add comment