我正在构建一个从web of Science中抓取引文数据的网络爬虫。上周五,我完成了程序的这一部分,但今天它停止工作了,当我试图通过Selenium访问引用数据时,我得到了一个NoSuchElementException。我尝试过使用不同的方法(id、class、xpath、css选择器)来单击这个特定的元素,但总是抛出错误。以下是我的代码,它曾经有效,但现在不起作用了:
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:
<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&SID=5FAYgZP1cYhuG9LGN3I&search_mode=CitingArticles&parentProduct=WOS&parentQid=18&parentDoc=12&REFID=84460199&excludeEventConfig=ExcludeIfFromNonInterProduct">313</a>
这是我今天收到的错误信息:
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)
我知道这里还有其他类似的问题,但他们都不能帮助我。谢谢!
https://stackoverflow.com/questions/56531256
复制相似问题