首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:使用Selenium ChromeDriver Chrome和Python无法定位元素

selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:使用Selenium ChromeDriver Chrome和Python无法定位元素
EN

Stack Overflow用户
提问于 2019-06-11 01:54:13
回答 1查看 1.3K关注 0票数 1

我正在构建一个从web of Science中抓取引文数据的网络爬虫。上周五,我完成了程序的这一部分,但今天它停止工作了,当我试图通过Selenium访问引用数据时,我得到了一个NoSuchElementException。我尝试过使用不同的方法(id、class、xpath、css选择器)来单击这个特定的元素,但总是抛出错误。以下是我的代码,它曾经有效,但现在不起作用了:

代码语言:javascript
复制
url = 'https://apps.webofknowledge.com/Search.do?product=UA&SID=8F2pCcE8ApJDSKZLHfF&search_mode=GeneralSearch&prID=acd62bc2-0ee0-47a1-a85d-12009db3c2f5'
driver.get(url)
citers_num = driver.find_element_by_class_name('snowplow-citation-network-times-cited-count-link')
citers_num.click()

下面是html:

代码语言:javascript
复制
<div class="search-results-data-cite">Times Cited: <a class="snowplow-    times-cited-link" title="View all of the articles that cite this one"     href="/CitingArticles.do     product=WOS&amp;SID=5FAYgZP1cYhuG9LGN3I&amp;search_mode=CitingArticles&amp;parentProduct=WOS&amp;parentQid=18&amp;parentDoc=12&amp;REFID=84460199&amp;excludeEventConfig=ExcludeIfFromNonInterProduct">313</a>

这是我今天收到的错误信息:

代码语言:javascript
复制
citers_num = driver.find_element_by_class_name('snowplow-citation-network-all-times-cited')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name
    return self.find_element(by=By.CLASS_NAME, value=name)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"class name","selector":"snowplow-citation-network-all-times-cited"}
  (Session info: chrome=75.0.3770.80)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.14.1 x86_64)  

我知道这里还有其他类似的问题,但他们都不能帮助我。谢谢!

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56531256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档