Поиск папки плагина Chrome в Windows 10: несколько методов с примерами кода

Чтобы найти папку плагина Chrome в Windows 10, вы можете воспользоваться несколькими способами. Вот несколько примеров с соответствующими фрагментами кода:

Метод 1. Использование папки AppData

import os
# Get the current user's AppData folder
appdata_folder = os.getenv('APPDATA')
# Construct the path to the Chrome plugin folder
chrome_plugin_folder = os.path.join(appdata_folder, 'Google\\Chrome\\User Data\\Default\\Extensions')
# Print the path to the Chrome plugin folder
print(chrome_plugin_folder)

Метод 2. Использование редактора реестра

import winreg
# Open the registry key for Chrome's installation path
key_path = r'Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path)
# Read the value of the "Path" key
chrome_install_path = winreg.QueryValue(key, None)
# Construct the path to the Chrome plugin folder
chrome_plugin_folder = os.path.join(chrome_install_path, 'User Data\\Default\\Extensions')
# Print the path to the Chrome plugin folder
print(chrome_plugin_folder)

Метод 3. Использование Chrome API (Python Selenium)

from selenium import webdriver
# Specify the path to the Chrome driver executable
chrome_driver_path = 'path/to/chromedriver.exe'
# Instantiate a Chrome driver
driver = webdriver.Chrome(executable_path=chrome_driver_path)
# Get the default Chrome profile's plugin folder
chrome_plugin_folder = driver.execute_script("return window.chrome.runtime.getManifest().path")
# Print the path to the Chrome plugin folder
print(chrome_plugin_folder)