Created
May 26, 2020 08:40
-
-
Save pepijndevos/84f85958ac0afb2c9cff341545f73c69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.common.action_chains import ActionChains | |
from selenium.common.exceptions import NoSuchElementException | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
driver = webdriver.Firefox() | |
driver.get("https://www.domijn.nl/mijndomijn/inloggen/") | |
assert "Domijn" in driver.title | |
current_url = driver.current_url | |
email = driver.find_element_by_name("Email") | |
email.clear() | |
email.send_keys("your email") | |
pw = driver.find_element_by_name("Password") | |
pw.clear() | |
pw.send_keys("your password") | |
pw.send_keys(Keys.RETURN) | |
WebDriverWait(driver, 15).until(EC.staleness_of(pw)) | |
driver.get("https://www.domijn.nl/woningaanbod/?view=&page=0&size=12&sorting=price-true&advertisementType=rent&rentalLimit=below&price-minimum2=147500&price-maximum2=389000&city=Enschede&rooms=3%2C4%2C5&price-minimum1=0&price-maximum1=737") | |
el = driver.find_elements_by_css_selector('#housingWrapper article a.js-clickable-link') | |
urls = [h.get_attribute('href') for h in el] | |
for url in urls: | |
print(url) | |
driver.get(url) | |
try: | |
btn = driver.find_element_by_id('react-submit_01') | |
except NoSuchElementException: | |
print("Already signed up") | |
continue | |
btn.click() | |
WebDriverWait(driver, 15).until(EC.staleness_of(btn)) | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment