1

I have a small seleniumbase parser which works fine with a list of auth proxies on Windows. After deploying it on ubuntu server, the code crashed with an exception:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:хххх from chrome not reachable

The sample code is as follows:

from seleniumbase import Driver

proxy = LOGIN:PASSWORD@IP:PORT

def get_browser():
    browser = Driver(
        uc=True,
        undetectable=True,
        headless=True,
        proxy=proxy
    )
    return browser

browser = get_browser()
browser.open(WEBSITE)

Without a proxy the parser works OK. I'd appreciate any clues as to what to fix in the code.

1 Answer 1

1

SeleniumBase's proxy-with-auth solution uses https://stackoverflow.com/a/35293284/7058266, which generates a Chrome extension at runtime for the proxy details. However, regular headless mode in Chrome doesn't support extensions. Although there is a newer headless mode for Chrome that does support extensions (https://stackoverflow.com/a/73840130/7058266), the optimal solution for SeleniumBase UC Mode to remain undetected in an Ubuntu environment with no display requires using a virtual display (https://stackoverflow.com/a/23447450/7058266).

SeleniumBase has its own modified version of pyvirtualdisplay called sbvirtualdisplay (https://github.com/mdmintz/sbVirtualDisplay). Just wrap your code with it. Here's an example

from sbvirtualdisplay import Display
from seleniumbase import Driver

display = Display(visible=0, size=(1440, 1880))
display.start()

driver = Driver(uc=True, proxy="USER:PASSWORD@IP:PORT")
driver.uc_open_with_reconnect("https://pixelscan.net/", reconnect_time=10)
# ...
driver.quit()

display.stop()

Since headless mode is the default mode on Linux, add headed=True to override that if the above doesn't work.

Sign up to request clarification or add additional context in comments.

1 Comment

Michael Mintz, thank you for your help. Now the parsing worked OK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.