【问题标题】:Scrapy + Selenium + DatepickerScrapy + Selenium + Datepicker
【发布时间】:2016-03-04 15:31:31
【问题描述】:

所以我需要废弃一个像this for example 这样的页面,并且我正在使用 Scrapy + Seleninum 与datepicker 日历进行交互,但我遇到了ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with

到目前为止我有:

def parse(self, response):

    self.driver.get("https://www.airbnb.pt/rooms/9315238")
    try:
        element = WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located((By.XPATH, "//input[@name='checkin']"))
        )
    finally:
        x = self.driver.find_element_by_xpath("//input[@name='checkin']").click()
        import ipdb;ipdb.set_trace()
        self.driver.quit()

我看到了一些关于如何实现 https://stackoverflow.com/a/25748322/977622https://stackoverflow.com/a/19009256/977622 的参考资料。

如果有人能帮助我解决我的问题,或者提供一个更好的例子来说明我如何与这个 datepicker 日历交互,我将不胜感激。

【问题讨论】:

  • 答案有帮助吗?谢谢。
  • 是的,抱歉,我花了太长时间才将其标记为正确

标签: selenium selenium-webdriver scrapy screen-scraping


【解决方案1】:

name="checkin" 有两个元素 - 您实际找到的第一个元素是不可见的。您需要使您的定位器更具体以匹配所需的输入。我也会改用visibility_of_element_located 条件:

element = WebDriverWait(self.driver, 10).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, ".book-it-panel input[name=checkin]"))
)

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 2018-02-04
    • 2017-05-25
    • 2016-04-28
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 2017-08-25
    相关资源
    最近更新 更多