【发布时间】:2021-09-09 19:53:13
【问题描述】:
我一直在尝试通过www.trivago.ie 网站自动检查酒店价格 我正在努力从您选择酒店后弹出的日历中选择日期。
我似乎无法获得正确的课程来允许我选择和更新开始日期和结束日期。我在下面附上了我的基本代码。有人可以帮我延长它,以便我可以在选择酒店后选择日期。
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
options.add_argument('window-size=2560,1440')
chrome_options = Options()
driver = webdriver.Chrome('*/drivers/chromedriver/win32/91.0.4472.101/chromedriver', chrome_options=options)
# Open the website page
driver.get('https://www.trivago.ie')
# Enter the hotel into the search box
driver.find_element_by_id("querytext").send_keys("test hotel")
# Allow time for options to populate
time.sleep(1)
# Select the first suggestion
driver.find_elements_by_class_name("ssg-suggestion__info")[0].click()
# Allow time for the calander to pop-up
time.sleep(3)
# Try, but fail, to select the date
#driver.find_elements_by_class_name("cal-day cal-is-weekend cal-is-selectable")[0].click()
driver.find_element_by_tag_name("cal-heading-month cal-heading-day4").click()
任何帮助将不胜感激,我已经遇到了很大的障碍。 谢谢。
【问题讨论】:
标签: python css selenium selenium-webdriver web-scraping