i am trying to get the availability/price for each day in airbnb by clicking the next button in the datepicker calendar but with no luck.
My current code is something like:
def handle(self, *args, **options):
def airbnb():
display = Display(visible=0, size=(1024, 768))
display.start()
driver = webdriver.Firefox()
driver.maximize_window()
driver.get("https://www.airbnb.pt/rooms/265820")
# wait for the check in input to load
wait = WebDriverWait(driver, 10)
elem = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.book-it-panel input[name=checkin]")))
elem.click()
# wait for datepicker to load
wait.until(
EC.visibility_of_element_located((By.CSS_SELECTOR, '.ui-datepicker:not(.loading)'))
)
days = driver.find_elements_by_css_selector(".ui-datepicker table.ui-datepicker-calendar tr td")
for cell in days:
day = cell.text.strip()
if not day:
continue
if "ui-datepicker-unselectable" in cell.get_attribute("class"):
status = "Unavailable"
else:
status = "Available"
price = "n/a"
if status == "Available":
# hover the cell and wait for the tooltip
ActionChains(driver).move_to_element(cell).perform()
price = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.datepicker-tooltip'))).text
print(day, status, price)
They both work but only for 1 month. I want to be able to set X months instead. For example for homeaway i tried with self.driver.find_element_by_css_selector('.ui-datepicker-next.ui-corner-all').click()
right after the first open calendar click but i got a ElementNotVisibleException
Thanks in advance