from selenium import webdriver
client = webdriver.Chrome()
client.get('https://sci-hub.tw/10.1021/cm0608903')
download_button = client.find_element_by_xpath("//cr-icon-button[@id='download']")
只有这么点,就报错了
报错信息如下Traceback (most recent call last):
File "E:/Data_storage/PyCharm/learn/LeetCode/Explore/test2.py", line 5, in <module>
download_button = client.find_element_by_xpath("//cr-icon-button[@id='download']")
File "D:\Install\Python-3.5.2\install\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "D:\Install\Python-3.5.2\install\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "D:\Install\Python-3.5.2\install\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\Install\Python-3.5.2\install\lib\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":"xpath","selector":"//cr-icon-button[@id='download']"}
(Session info: chrome=81.0.4044.129)
还有,是不是找到之后用.click()就能实现下载呢 |