硒找不到元素-没有这样的元素

丹尼尔

我在这个网站上想要获取元素标题。

我试过了,driver.find_element_by_class_name("sc-1di2uql-1 vYcWR")但是只返回了:selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{“ method”:“ css选择器”,“ selector”:“。sc-1di2uql-1 vYcWR”}

我曾看到过类似的帖子,其中的问题是搜索到的元素在iframe中,但我在这里看不到任何类似的信息。然后大约一周前,我再次开始学习网络爬虫,所以我可能不了解很多内容。

坎图尼

I had a similar issue with selenium before. My problem was that the website would rotate class names, so every time you access the page they would be different. Judging by the way the class names are on your website I think you have the same issue. If this is the case, you are just trying to look for something that is not there. What I did to solve this problem was using driver.get_element_by_xpath(“PASTE FULL XPATH OF THE ELEMENT”) instead of finding the element using its css class.

To get the full path of an element: in the developer tools, right click on the element and click copy FULL XPATH.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章