错误:试图使用Selenium在Python上运行映像下载程序时,进程\u reader_win.cc(123)]n线程:{Access Denied}

错误:试图使用Selenium在Python上运行映像下载程序时,进程\u reader_win.cc(123)]n线程:{Access Denied},python,selenium,google-chrome,selenium-webdriver,selenium-chromedriver,Python,Selenium,Google Chrome,Selenium Webdriver,Selenium Chromedriver,在尝试访问目录之前,代码运行正常。 感谢您的任何意见 代码如下: from selenium import webdriver from selenium.webdriver.chrome.options import Options import os import ast import requests import urllib.request from bs4 import BeautifulSoup as Soup opts = Options() opts.add_argume

在尝试访问目录之前,代码运行正常。 感谢您的任何意见

代码如下:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
import ast
import requests
import urllib.request
from bs4 import BeautifulSoup as Soup


opts = Options()

opts.add_argument("user-agent=chrome/23.0.1271")

driver = webdriver.Chrome("./chromedriver.exe")

url = 'https://s.aolcdn.com/os/ab/_cms/2020/09/09081722/568224.jpg'
directory = 'RAW'
FILETYPE = '.jpg'

r = requests.get(url,allow_redirects=True)



def find_urls(url):
    driver.get(url)
    wait = input('loading...lmao')
    page = driver.page_source

    soup = Soup(page,'lxml')
    images = soup.find_all('img',{"src":True})

all_images = []

for image in images:
    image_src = image['src']
    print(image_src)
    
    urllib.request.urlretrieve(image_src)


Images = find_urls(url)





def save_img(Image,directory):
    if not os.path.isdir(directory):
        os.mkdir(directory)

            
for i,link in enumerate(url):
    path = os.path.join(directory,'(:06).jpg'.format(i))
    try:
        ulib.urlretrieve(link,path)
    except:
        print('Failed:')

            
save_img(Images,directory)
我想这可能是我访问目录的方式,但我尝试的东西已经用完了。我已检查文件夹,确保以管理员身份运行。

此错误消息

ERROR:process_reader_win.cc(123)] NtOpenThread: {Access Denied}
…表示ChromeDriver启动的线程无法读取系统资源,因为访问被拒绝


根本原因 拒绝访问的一个常见原因是在Linux上以root用户(
管理员)身份运行Chrome。虽然可以通过在创建WebDriver会话时传递
--no sandbox
标志来解决此问题,但这样的配置不受支持,并且非常不推荐。您需要将您的环境配置为以普通用户身份运行Chrome


额外考虑 确保:

  • Selenium已升级到当前版本
  • ChromeDriver已更新到当前级别
  • Chrome更新到当前的Chrome版本84.0级别。(根据)
  • 如果您的基本Web客户端版本太旧,请卸载它并安装最新的GA和Web客户端发布版本
  • 通过IDE清理项目工作区,并仅使用所需的依赖项重建项目
  • 重新启动系统
  • 以非root用户身份执行
    @Test
  • 始终在
    tearDown(){}
    方法中调用
    driver.quit()
    ,以优雅地关闭和销毁Web驱动程序和Web客户端实例