我想通過點擊datepicker日曆中的下一個按鈕來獲取homeaway中每一天的價格,但沒有運氣。從datepicker獲取可用性
我當前的代碼是一樣的東西:
def handle(self, *args, **options):
def homeaway(self):
display = Display(visible=0, size=(1024, 768))
display.start()
driver = webdriver.Firefox()
driver.maximize_window()
wait = WebDriverWait(driver, 10)
url = 'https://www.homeaway.pt/arrendamento-ferias/p1418427a?uni_id=1590648'
driver.get(url)
# pick start date
start_date = wait.until(EC.visibility_of_element_located((
By.CSS_SELECTOR,
".quotebar-container input[name=startDateInput]")))
start_date.click()
first_available_date = wait.until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "#ui-datepicker-div td.full-changeover > a")))
ActionChains(driver).move_to_element(first_available_date).perform()
driver.find_element_by_css_selector(
"#ui-datepicker-div td.full-selected.full-changeover > a").click()
# pick end date (TODO: violates DRY principle, refactor!)
end_date = wait.until(EC.visibility_of_element_located(
(By.CSS_SELECTOR, ".quotebar-container input[name=endDateInput]")))
end_date.click()
first_available_date = wait.until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "#ui-datepicker-div td.full-changeover > a")))
ActionChains(driver).move_to_element(first_available_date).perform()
driver.find_element_by_css_selector(
"#ui-datepicker-div td.full-selected.full-changeover > a").click()
# get the calculated price
price = wait.until(EC.visibility_of_element_located(
(By.CSS_SELECTOR, ".price-quote .price-total")))
print(price.text.encode('ascii', 'ignore'))
driver.close()
他們都工作,但只有1個月。我希望能夠設置X個月。例如,對於HomeAway的我試着用self.driver.find_element_by_css_selector('.ui-datepicker-next.ui-corner-all').click()
首開日曆點擊後的權利,但我得到了提前
我會嘗試以後,讓你知道,謝謝 – psychok7
嗨,我仍然得到了'ElementNotVisibleException'與您的代碼:( – psychok7