from selenium import webdriver
driver = webdriver.Chrome()
driver = webdriver.Chrome(
r'C:\Users\New User prof\Downloads\chromedriver_win32.zip\chromedriver.exe')
driver.get(
"https://www.google.com/webmasters/tools/url-removal?hl=en&siteUrl=https://www.greatbuyz.com/&mesd=AB9YKzIL4DBt4yX8SVayjC2kUq8yeXctK_u2WGH4KlESTcjXkcOsdBvVP7TnX4S4bBF4PADFQzZAxIqcxMiVerW67kTw-UGIWjHVftlzX5DNcJjm3Uz5wBpWxkDYY7IIFlVMdiEvTsAG_GwgA_DqO7Exg5w80HGHX_lk4okr-Ay7vrCG63zKVLrMGmyNMUPGEESjX2rJF-Xx&authuser=2")
driver.find_element_by_xpath(
"//button[@class='goog-inline-block jfk-button jfk-button-standard']").click()
错误:
Traceback (most recent call last):
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib64/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bot.py", line 4, in <module>
driver = webdriver.Chrome()
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
答案 0 :(得分:0)
我不是百分之百确定这是问题所在。如果路径中有空格,则有时Windows中无法识别该路径。您可以尝试在路径周围添加其他双引号。
driver = webdriver.Chrome(
r'"C:\Users\New User prof\Downloads\chromedriver_win32.zip\chromedriver.exe"')
我无法确定天气是否需要提取。我现在不使用Windows,因此无法测试。
答案 1 :(得分:0)
尝试下面的代码
from selenium import webdriver
driver = webdriver.Chrome(
'C:/Users/New User prof/Downloads/chromedriver_win32.zip/chromedriver.exe')
driver.get("URL")
driver.find_element_by_xpath("//button[@class='goog-inline-block jfk-button jfk- button-standard']").click()