Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Selenium webdriver.Chrome会导致PermissionError:[WinError 5]访问被拒绝_Python_Selenium Webdriver_Web Scraping_Selenium Chromedriver - Fatal编程技术网

Python 使用Selenium webdriver.Chrome会导致PermissionError:[WinError 5]访问被拒绝

Python 使用Selenium webdriver.Chrome会导致PermissionError:[WinError 5]访问被拒绝,python,selenium-webdriver,web-scraping,selenium-chromedriver,Python,Selenium Webdriver,Web Scraping,Selenium Chromedriver,我试图从()中获取评论,但当我运行代码时: from selenium import webdriver chrome_path = r"C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\Scripts" driver = webdriver.Chrome(chrome_path) driver.get("https://boxes.mysubscriptionaddiction.com/box/boxycharm?

我试图从()中获取评论,但当我运行代码时:

from selenium import webdriver
chrome_path = r"C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\Scripts"
driver = webdriver.Chrome(chrome_path)

driver.get("https://boxes.mysubscriptionaddiction.com/box/boxycharm?ratings=true#review-update-create")
review = driver.find_element_by_class_name("comment-body")
for post in review:
    print(post.text)
我得到了以下错误。我需要做什么来解决这个问题

"C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\python.exe" "C:/Users/Sara Jitkresorn/PycharmProjects/untitled/venv/SubsAddict.py"
Traceback (most recent call last):
  File "C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1155, 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:/Users/Sara Jitkresorn/PycharmProjects/untitled/venv/SubsAddict.py", line 3, in <module>
    driver = webdriver.Chrome(chrome_path)
  File "C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Scripts' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
“C:\Users\Sara-Jitkresorn\AppData\Local\Programs\Python\Python37\Python.exe”“C:/Users/Sara-Jitkresorn/PycharmProjects/untitled/venv/subsaddint.py”
回溯(最近一次呼叫最后一次):
文件“C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\site packages\selenium\webdriver\common\service.py”,第76行,开头
标准偏差=管道)
文件“C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\subprocess.py”,第756行,在\uuu init中__
恢复信号,启动新会话)
文件“C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\lib\subprocess.py”,第1155行,在执行子进程中
startupinfo)
PermissionError:[WinError 5]访问被拒绝
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:/Users/Sara-Jitkresorn/PycharmProjects/untitled/venv/substainct.py”,第3行,在
driver=webdriver.Chrome(Chrome\u路径)
文件“C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\37\lib\site packages\selenium\webdriver\chrome\webdriver.py”,第73行,在\uu init中__
self.service.start()
文件“C:\Users\Sara-Jitkresorn\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py”,第88行,开头
os.path.basename(self.path)、self.start\u错误消息)
selenium.common.exceptions.WebDriverException:消息:“脚本”可执行文件可能具有错误的权限。请看https://sites.google.com/a/chromium.org/chromedriver/home
  • 您应该将所有“\”替换为“/”
  • 您的chrome路径错误,您需要找到chrome可执行文件的路径,它应该存储在程序文件或程序文件x86 Google子文件夹中
  • 您应该将所有“\”替换为“/”
  • 您的chrome路径错误,您需要找到chrome可执行文件的路径,它应该存储在程序文件或程序文件x86 Google子文件夹中
    是的,我刚刚注意到了。我已经用
    driver=webdriver.Chrome(executable\u path=r'C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\Scripts\chromedriver\\chromedriver.exe')替换了第二行和第三行。
    我刚才注意到了。我已将第2行和第3行替换为
    driver=webdriver.Chrome(可执行文件\u path=r'C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python37\Scripts\chromedriver\\chromedriver.exe')