我以这种方式添加铬选项,如果我使用代理ip身份验证,它可以工作。
options = webdriver.ChromeOptions()
options.headless = True
options.add_argument('--proxy-server=92.128.165.143:3399')
driver = uc.Chrome(options=options)
但是,我有一个具有这种格式的身份验证的代理:http://username:password@91.92.128.165.143:3399
如果我把它加起来
options.add_argument('--proxy-server=http://username:password@91.92.128.165.143:3399')
它不起作用。我如何添加用户名/密码呢?这仅适用于未检测到的铬驱动程序。
发布于 2022-09-12 23:53:57
我想我已经通过selenium钢丝实现了它,但是它不适用于kivy gui,所以对于脚本编写,您可以这样做,但是如果您想要与kivy一起使用,那么肯定会出错
from ast import Try
from pathlib import Path
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.proxy import *
from seleniumwire import undetected_chromedriver as uc
from fake_useragent import UserAgent
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from pyclick import HumanClicker
import pyautogui
import time
clicked=False
hostname = "188.74.183.126"
port = "8395"
proxy_username = "wclmiemy"
proxy_password = "a9hoxl4phkzr"
chrome_options = {
'proxy': {
'http': f'http://{proxy_username}:{proxy_password}@{hostname}:{port}',
'https': f'https://{proxy_username}:{proxy_password}@{hostname}:{port}',
'no_proxy': 'localhost,127.0.0.1'
}
}
def delete_cache(driver):
driver.execute_script("window.open('')") # Create a separate tab than the main one
driver.switch_to.window(driver.window_handles[-1]) # Switch window to the second tab
driver.get('chrome://settings/clearBrowserData') # Open your chrome settings.
pyautogui.click("clear_data.png")
if __name__ == '__main__':
email = "moqaddasmehran5@gmail.com"
password = "moqaddaszaheenzaheen"
ua = UserAgent()
userAgent = ua.random
options = webdriver.ChromeOptions()
options.add_argument(f'user-agent={userAgent}')
# options.add_argument('--ignore-certificate-errors-spki-list')
# # options.add_argument('--ignore-ssl-errors')
options.add_argument("--disable-infobars")
browser = uc.Chrome(
driver_executable_path="chromedriver",
seleniumwire_options=chrome_options,
options=options,
use_subprocess=True
)
browser.maximize_window()
browser.get('https://www.youtube.com/watch?v=uPxkrGL0l7U')
```
this code is kind of messy but im in Hurry hope you will be able to modify you willa also get ssle that you need to import in chrome thats it you will defnitely get it
发布于 2022-05-18 20:03:14
使用以下代码添加具有用户名和密码的代理:
from selenium import webdriver
PROXY = "http://username:password@91.92.128.165.143:3399"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(chrome_options=chrome_options)
编辑:
我找到了这个how to set proxy with authentication in selenium chromedriver python?
https://stackoverflow.com/questions/72295280
复制相似问题