I've written some code in python in combination with selenium to collect photo shoot spaces in different locations in Paris.
My scraper is harvesting the names successfully at this moment. However, is it possible to do this any better way cause it looks repetitive?
Any input to improve this script will be highly appreciated. Here is what I've written:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://www.peerspace.com/")
wait = WebDriverWait(driver, 10)
wait.until(EC.visibility_of_element_located((By.ID, "activity-input"))).click()
wait.until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class,'ellipsis')]/a"))).click()
wait.until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class,'col-xs-12')]/li/a[@data-name='Photo Shoot']"))).click()
wait.until(EC.visibility_of_element_located((By.ID, "searchbar-input"))).send_keys("Paris")
wait.until(EC.visibility_of_element_located((By.ID,"searchbar-submit-button"))).click()
for items in wait.until(EC.presence_of_all_elements_located((By.XPATH, "//div[@class='col-xs-12 ']/h6[contains(@class,'title')]"))):
print(items.text)
driver.quit()
Inputbox to be filled in before pressing the search button are with:
First one : Photo Shoot
Second one : Paris