【问题标题】:Using Selenium webdriver.Chrome results in PermissionError: [WinError 5] Access is denied [duplicate]使用 Selenium webdriver.Chrome 导致 PermissionError: [WinError 5] Access is denied [重复]
【发布时间】:2020-06-20 12:48:53
【问题描述】:

我正在尝试从 (https://boxes.mysubscriptionaddiction.com/box/boxycharm?ratings=true#review-update-create) 中抓取评论,但是当我运行代码时:

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

【问题讨论】:

    标签: python selenium-webdriver web-scraping selenium-chromedriver


    【解决方案1】:
    1. 您应该将所有“\”替换为“/”。
    2. 您的 chrome 路径错误,您需要找到 chrome 可执行文件的路径,它应该存储在 Program Files 或 Program Files x86 Google 子文件夹中。

    【讨论】:

    • 是的,我刚刚注意到。我已经用 driver = webdriver.Chrome(executable_path=r'C:\Users\Sara Jitkresorn\AppData\Local\Programs\Python\Python37\Scripts\chromedriver\\chromedriver.exe') 替换了第 2 行和第 3 行
    猜你喜欢
    • 2017-08-14
    • 2021-01-10
    • 2016-07-21
    • 1970-01-01
    • 2022-01-25
    • 2021-03-23
    • 2020-07-22
    • 1970-01-01
    相关资源
    最近更新 更多