【发布时间】:2022-01-12 08:40:08
【问题描述】:
我正在尝试从该网站抓取历史天气数据: https://www.worldweatheronline.com/taoyuan-weather-history/tai-wan/tw.aspx
使用此代码:
driver.find_element_by_css_selector("input[type='date']").send_keys(str(for_weather.mm[i])+str(for_weather.dd[i])+for_weather.year[i].astype(str))
wait=WebDriverWait(driver,10)
wait.until(EC.element_to_be_clickable((By.ID,'ctl00_MainContentHolder_butShowPastWeather'))).click()
temp=driver.find_element_by_xpath('//div[@class="days-collapse-temp"]').get_attribute('innerHTML')
我看到了显示如何选择和关闭弹出窗口的帮助,但就我而言,我们不知道它们何时会出现。在某些页面上会出现,有些则不会。当它们出现时,它们会阻止我获取我想要的数据,并停止循环。以下是错误信息(具有弹窗的特点):
ElementClickInterceptedException: element click intercepted: Element <input type="submit" name="ctl00$MainContentHolder$butShowPastWeather" value="Get Weather" id="ctl00_MainContentHolder_butShowPastWeather" class="btn btn-success ml-2"> is not clickable at point (956, 559). Other element would receive the click: <div class="introjs-overlay" style="inset: 0px; position: fixed; cursor: pointer;"></div>
(Session info: chrome=97.0.4692.71)
非常感谢!
【问题讨论】:
标签: python-3.x selenium popup