我四处查看了两个文档,但没有找到答案。
我一直在尝试为Python使用InstaPy instagram API。在因多个错误而失败并假设InstaPy仅存在一些问题之后,我尝试使用 Selenium 精对其进行原始编码。插入示例代码并将其更改为我喜欢的方式后,我只是确保此代码可以正常工作。我收到一个新的错误,而不是旧的错误,说权限可能不正确。我尝试重新安装并以管理员身份运行,但没有任何效果。我该如何解决和/或这意味着什么
代码:
import time
from selenium import webdriver
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()
错误:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Webdrivers\RawBot.py", line 5, in <module>
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
最佳答案
此错误消息...
WebDriverException: Message: 'Webdrivers' executable may have wrong permissions.
...暗示您尝试使用的ChromeDriver版本具有错误的权限。
您似乎已经尝试过:
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search system $PATH variable.
几句话:
(/)
和原始(r)
开关,或者必须使用转义的backslash即(\\)
。 driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
(/)
。 driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
chromedriver
二进制路径时,您必须使用单个forward slash即(/)
。 driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
关于python - “Webdrivers”可执行文件可能具有错误的权限。请参阅https ://sites. google.com/a/chromium.org/chromedriver/home,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47148872/