wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.89k stars 249 forks source link

Don't working with proxy #534

Open Petr2282 opened 2 years ago

Petr2282 commented 2 years ago

Hi wkeeling, I am trying simply to intercept requests and all working without using proxy, but when connect to any proxy using seleniumwire_options it starts to return non type obejcts.

wkeeling commented 2 years ago

Can you explain what you mean about "non type obejcts"? Do you have some code that demonstrates the problem?

Petr2282 commented 2 years ago

elif driver == Driver.FIREFOX:

    options = webdriver.FirefoxOptions()
    options.headless = headless
    options.set_preference(
        "general.useragent.override",
        f"{generate_useragent('firefox')}"
    )
    options.set_preference("dom.webdriver.enabled", False)
    options.binary_location = FIREFOX_PATH

    options.proxy = p2({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': proxy,
        'ftpProxy' : proxy,
        'sslProxy' : proxy,
        'noProxy'  : ''
    })
    print("Proxy: " + proxy)

    woptions = {
        'proxy': {
            'http': 'http://' + proxy,
            'https': 'https://' + proxy
        }
    }
    return webdriver.Firefox(
        seleniumwire_options=woptions,
        executable_path=GECKODRIVER_PATH,
        options=options
    )
else:
    raise Exception("Unknown driver type")
Petr2282 commented 2 years ago

Can you explain what you mean about "non type obejcts"? Do you have some code that demonstrates the problem?

example of set up

alimp5 commented 2 years ago

@Petr2282

    options.proxy = p2({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': proxy,
        'sslProxy' : proxy,
        'noProxy'  : ''
    })

or:


    options.proxy = p2({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': proxy,
        'sslProxy' : proxy,
    })

firefox no longer support ftp-proxy.

wkeeling commented 2 years ago

@Petr2282 is this issue still affecting you?

I notice in your code above that you're trying to set the upstream proxy with:

    options.proxy = p2({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': proxy,
        'ftpProxy' : proxy,
        'sslProxy' : proxy,
        'noProxy'  : ''
    })

This configuration shouldn't be used for upstream proxies - only use seleniumwire_options.