[Python] Message: invalid argument: unrecognized capability: acceptSslCerts Stacktrace:...

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    Please handle me to solve this error. I want to scraping using selenium webdriver and rotating proxy, so i have to set up the proxy but i don't know what is the correct configuration to do that so just got this error. What is wrong with my configuration?


    from selenium import webdriver
    import time
    import requests
    from bs4 import BeautifulSoup

    PATH = r'chromedriver.exe'

    def listProxies():
    """Get List of Free Proxy."""
    r = requests.get('https://free-proxy-list.net/')
    soup = BeautifulSoup(r.content, 'html.parser')
    table = soup.find('tbody')

    proxies = []
    for row in table:
    if row.find_all('td')[4].text == 'elite proxy':
    proxy = ':'.join([row.find_all('td')[0].text, row.find_all('td')[1].text])
    proxies.append(proxy)
    else:
    pass
    return proxies

    def getProxy(prox):
    proxy = {"http": f"http://{prox}",
    "https": f"http://{prox}"
    }
    return proxy

    def getProx():
    """Choose and get available Proxy from list"""
    proxies = listProxies()
    for prox in proxies:
    # Free proxy (IP:pORT format from SSLProxies)
    proxy = getProxy(prox)
    try:
    print(f"trying proxy:{proxy}...")
    response = requests.get("http://httpbin.org/ip", proxies=proxy, timeout=5)
    if response.status_code == 200:
    print("Yay, its working! Proxy is working:", response.json()) # Should return the proxy's IP if working
    return prox
    else:
    print("Proxy failed, switching...") # Get a new one
    break
    except requests.exceptions.RequestException as e:
    print(f"Proxy failed: {e}. Trying another one")

    def start_driver():
    """Starts Selenium WebDriver with a random proxy."""
    prox = getProx() # (Update regularly or use a free-proxy)
    proxy = getProxy(prox)
    webdriver.DesiredCapabilities.CHROME['proxy'] = {
    "httpProxy": prox,
    "ftpProxy": prox,
    "sslProxy": prox,
    "proxyType": "MANUAL",
    }
    webdriver.DesiredCapabilities.CHROME['acceptSslCerts']=True
    driver =webdriver.Chrome(service = webdriver.ChromeService(executable_path=PATH))
    return driver



    My Running Code


    """Running Code"""
    try:
    driver = start_driver()
    driver.get("'http://whatismyipaddress.com'")
    except Exception as e:
    print(f"Proxy failed: {e}. Retrying with a new proxy...\n")
    time.sleep(3) # Wait before retrying
    print("Done.")



    It gives me error message:


    Message: invalid argument: unrecognized capability: acceptSslCerts Stacktrace:
    GetHandleVerifier [0x00007FF7F3396EE5+28773]
    (No symbol) [0x00007FF7F33025D0]
    (No symbol) [0x00007FF7F3198FAA]...etc



    Ijust using free proxy, is it still possible to do so? Fyi I have update my selenium to the newest version: 4.29.0 Thank you for your kind help, everyone!

    Continue reading...

Compartilhe esta Página