Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- from selenium import webdriver
- from selenium.webdriver import Chrome
- from selenium.webdriver.chrome.service import Service
- from selenium.webdriver.chrome.options import Options
- from selenium.webdriver.common.action_chains import ActionChains
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.wait import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.common.exceptions import *
- ##Chrome Options#
- serv = Service("<PATH>")
- opts = Options()
- opts.headless = False
- opts.add_argument("--start-maximized")
- opts.binary_location = "<PATH>
- driver = Chrome(service=serv, options=opts)
- driver.get('https://www.connectcre.com/chicago-midwest/')
- innerHTML = driver.execute_script("return document.body.innerHTML")
- soup = BeautifulSoup(innerHTML, "lxml")
- element = driver.find_element(By.CSS_SELECTOR, ("div[id='ajax-load-more-2'] button[type='button']"));
- driver.execute_script("return arguments[0].scrollIntoView();", element);
- innerHTML = driver.execute_script("return document.body.innerHTML")
- print("Success")
- print(soup)
- botton_to_click = WebDriverWait(driver, 45).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ("div[id='ajax-load-more-2'] button[type='button']"))))
- innerHTML = driver.execute_script("return document.body.innerHTML")
- botton_to_click.click()
- print("click")
- botton_to_click.click()
- print("click 2")
- driver.close
Advertisement
Add Comment
Please, Sign In to add comment