1

I want to connect to a chrome browser that i have started with the launch command

await launch(headless=False, \
            executablePath ="C:/Program Files/Google/Chrome/Application/chrome.exe",\
            args=["--remote-debugging-port=9222"])

with the connect command

browser=await pyppeteer.connect(browserURL='http://127.0.0.1:9222')

but it looks that this is not right.

if i open the browser with command line

chrome_path = 'C:/Program Files/Google/Chrome/Application/chrome.exe '
cmdCommand = chrome_path + " --remote-debugging-port=9222"
subprocess.Popen(cmdCommand.split(), stdout=subprocess.PIPE)

then pyppeteer.connect works fine.

Teodoros
  • 459
  • 4
  • 14

1 Answers1

0

Whether you are using python or javascript or any other tools, e.g. puppeteer-stealth package, you need to first launch and then get the wsEndpoint and connect it via pyppeteer.connect

pup = await launch(headless=False, \
            executablePath ="C:/Program Files/Google/Chrome/Application/chrome.exe",\
           );
endpoint = pup.wsEndpoint()

pyppeteer.connect(browserWSEndpoint = endpoint )

if you are trying to connect by specifying --remote-debugging-port, you have a typo on the option.

Hossein Alipour
  • 575
  • 5
  • 9
  • endpoint = pup.wsEndpoint() is working fine but launch with --remote-debugging-port still doesn't work, even if i have first open the browser with commacd line or not, i get "Browser closed unexpectedly" – Teodoros Nov 17 '21 at 12:32
  • it is pup.wsEndpoint not pup.wsEndpoint() – Teodoros Nov 17 '21 at 15:43
  • are you on the same host or you are trying to access from remote? why don't you just use wsendpoint? – Hossein Alipour Nov 18 '21 at 02:01