You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The project launches the Chrome process within the uc.Chrome.__init__ function,
which appears to make it impossible to utilize Chrome browser on other machine.
Below is the pseudocode as an example, since the original function is too lengthy.
It allows you to use the server's undetected_chromedriver to access the chrome browser on your desktop PC.
Note:
It is necessary to manually launch the Chrome browser before running the code.
Port forwarding is required, as Chrome remote-debugging only accepts access from local addresses.
You need to manage the Chrome process yourself, as it is not controlled by undetected_chromedriver.
# It is necessary to launch the Chrome process and port forwarding in advance.# ./chrome.exe --remote-debugging-port=9222 --user-data-dir=remote-profile# ssh -R localhost:9222:localhost:9222 [email protected]classMyChrome(uc.Chrome):
def__init__(
self,
# ....# other code# ....use_local_browser: bool=True,
):
# ....# other code# ....ifuse_local_browser:
ifnotuse_subprocess:
self.browser_pid=start_detached(
options.binary_location, *options.arguments
)
else:
browser=subprocess.Popen(
[options.binary_location, *options.arguments],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=IS_POSIX,
)
self.browser_pid=browser.pid# ....# other code# ....driver=MyChrome(use_local_browser=False)
driver.get('https://example.com')
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The project launches the Chrome process within the
uc.Chrome.__init__
function,which appears to make it impossible to utilize Chrome browser on other machine.
Below is the pseudocode as an example, since the original function is too lengthy.
It allows you to use the server's undetected_chromedriver to access the chrome browser on your desktop PC.
Note:
Beta Was this translation helpful? Give feedback.
All reactions