【发布时间】:2019-06-30 13:31:55
【问题描述】:
我正在从网站 (Investing.com) 抓取一些数据,偶尔会弹出一个窗口。我在元素中寻找了一个可点击的按钮,但找不到任何东西。
这是来自元素页面的片段,其中 元素是我能找到的与要关闭的“X”相关的所有内容。
...
<div class="right">
<i class="popupCloseIcon largeBannerCloser">
::after
</i>
...
我试过的代码如下:
from selenium.webdriver import ChromeOptions as Options
import selenium.webdriver as webdriver
chrome_options = Options()
#chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
d = webdriver.Chrome('chromedriver', options=chrome_options)
d.get("https://www.investing.com/currencies/eur-usd-technical")
iElements = d.find_elements_by_tag_name("i")
for name in iElements:
print(name.get_attribute("class"))
if name.get_attribute("class") == "popupCloseIcon largeBannerCloser":
print("im here")
name.click()
我打印我的文本并到达那里,所以知道我找到了我的元素,但最终出现以下错误:
selenium.common.exceptions.ElementNotInteractableException:消息: 元素不可交互
找不到其他可以互动的东西吗?
【问题讨论】:
-
发现这个有点远,不知道它是否有帮助?
标签: javascript python selenium web-scraping beautifulsoup