Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I would like to use puppeteer with my current chrome (keeping my credentials) #3543

Closed
lucasteisseire opened this issue Nov 14, 2018 · 18 comments

Comments

@lucasteisseire
Copy link

i'm actually trying to use puppeteer for scraping and i need to use my current chrome to keep all my credentials and use it instead of relogin and type password each time which is a really time lose !

is there a way to connect it ? how to do that ?
i'm actually using node v11.1.0
and puppeteer 1.10.0

let scrape = async () => {
    const browser = await log()
    const page = await browser.newPage()           
    const delayScroll = 200
// Login 
await page.goto('somesite.com');
await page.type('#login-email', '*******);
await page.type('#login-password', "******");
await page.click('#login-submit');
// Wait to login
await page.waitFor(1000);

}
and now it will be perfect if i do not need to use that and go on page (headless, i dont wan't to see the page opening i'm just using the info scraping in node) but with my current chrome who does not need to login to have information i need. (because at the end i want to use it as an extension of chrome)

thx in advance if someone knows how to do that

@aslushnikov
Copy link
Contributor

@lucasteisseire in order to run puppeteer against stable chrome, you should do the following:

  1. Figure the version of your stable chrome installation (in your stable chrome, navigate to about:version)
  2. Figure out matching Puppeteer version in our api.md
  3. Install puppeteer-core
  4. Use puppeteer-core to launch the stable chrome, passing the executablePath option:
const pptr = require('puppeteer-core');
(async () => {
  const browser = await pptr.launch({
    executablePath: '<path-to-my-chrome-exec>'
  });
  // ... go on...
})();

Hope this helps.

@pratik-joshi-cactus
Copy link

Not working :/ in Version 75.0.3770.100 (Official Build) (64-bit), It still opens up new instance of chrome and it has no history whatsoever, I had to open it along with my other chrome tabs.

const puppeteer = require('puppeteer');
const pptr = require('puppeteer-core');
(async () => {

	const browser = await puppeteer.launch({
	  headless: false,
	  executablePath: '/usr/bin/google-chrome'
	});

})(); 

Here I also tried puppeteer-core , means pptr variable await pptr.launch in above variable, still not working. The issues is not closed!
Please check :
https://drive.google.com/file/d/1WKjgPeruK9-ABeHHsumhcjs_FTlzFH4S/view

@mcarneiro
Copy link

@alex2844
Copy link
Contributor

alex2844 commented Sep 19, 2019

@lucasteisseire in order to run puppeteer against stable chrome, you should do the following:

  1. Figure the version of your stable chrome installation (in your stable chrome, navigate to about:version)
  2. Figure out matching Puppeteer version in our api.md
  3. Install puppeteer-core
  4. Use puppeteer-core to launch the stable chrome, passing the executablePath option:
const pptr = require('puppeteer-core');
(async () => {
  const browser = await pptr.launch({
    executablePath: '<path-to-my-chrome-exec>'
  });
  // ... go on...
})();

Hope this helps.

not working

        var browser, page;
        browser = await puppeteer.launch({
            executablePath: '/usr/bin/chromium', 
            userDataDir: '/tmp/browser'                                                                                                                
        });
        page = await browser.newPage();
        await page.goto('https://gmail.com/');
        await browser.close();
        browser = await puppeteer.launch({
            headless: false,
            executablePath: '/usr/bin/chromium',
            userDataDir: '/tmp/browser'
        });
        page = await browser.newPage();
        await page.goto('chrome://history/'); // history empty

@urosran
Copy link

urosran commented Oct 9, 2019

The instructions above launch headless chrome

from chrome//about :
Google Chrome | 77.0.3865.90 (Official Build) (64-bit) (cohort: Stable)
Chromium 77.0.3803.0 should be Puppeteer v1.19.0 (per github link above)
npm list
+-- puppeteer@1.19.0
+-- puppeteer-core@1.19.0

code:
``
const pptr = require('puppeteer-core');
(async () => {
const browser = await pptr.launch({
executablePath: 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
});

const page = await browser.newPage();
await page.goto('https://www.airbnb.com/');
console.log(page.url())
})();

``

runs in console and logs the correct url

@Ramanth
Copy link

Ramanth commented Jan 22, 2020

what is the minimum version of chrome required?
i have to automate a chrome v61 which is opened already in remote-debugging-mode?

@ashminbhandari
Copy link

ashminbhandari commented Apr 12, 2020

Hey guys, I found a solution to this problem. So you can input the path to your userDataDir as part of the puppeteer launch parameters. Look for profile path by executing chrome://version in your browser. Doing this, puppeteer executed itself in the same chrome window that I am currently using.

pptr.launch({headless: false,
  executablePath: '[insert executable path here]',
  userDataDir: '[insert profile path or user directory path here]'}).then(async browser => {
});

@ORESoftware
Copy link

@ashminbhandari puppeteer-core or puppeteer?

@ashminbhandari
Copy link

@ORESoftware OOF, I believe it was puppeteer-core but I am not 100%

@ORESoftware
Copy link

@ashminbhandari yeah I am looking for an answer to #5756

@eduardoewgo
Copy link

eduardoewgo commented May 2, 2020

Any progress on this, @ORESoftware ?

I've been trying to use my installed version for a while now :/..

The idea is to keep all my browser information/credentials while running puppeteer.

@ashminbhandari
Copy link

@ORESoftware Are you in a position to use something else? I switched to Selenium when I ran into this problem. And I believe it is suggested that you instead copy your profile directory and provide the path to that instead because running two instances on the same profile directory causes problems.

@matheuscch
Copy link

matheuscch commented May 25, 2020

I'm using something like that.

My idea is to make the puppteer open in a url window, to be inserted into a page at run time

No answer so far

@eduardoewgo
Copy link

@matheuscch

Try this

  1. create a new chrome shortcut on your desktop and add --remote-debugging-port=9222 to the target.
  2. open it using the just created shortcut and go to http://127.0.0.1:9222/json/version

This json should give you the webSocketDebuggerUrl, which you case use to connect to the instance. If I'm not wrong it should be something like

await puppeteer.connect({browserWSEndpoint: webSocketDebuggerUrl})

@imvetri
Copy link

imvetri commented Feb 26, 2024

Hey guys, I found a solution to this problem. So you can input the path to your userDataDir as part of the puppeteer launch parameters. Look for profile path by executing chrome://version in your browser. Doing this, puppeteer executed itself in the same chrome window that I am currently using.

pptr.launch({headless: false,
  executablePath: '[insert executable path here]',
  userDataDir: '[insert profile path or user directory path here]'}).then(async browser => {
});

Executable path and userDataDir can be found here
chrome://version/

@singladno
Copy link

singladno commented Apr 8, 2024

Hey guys, I found a solution to this problem. So you can input the path to your userDataDir as part of the puppeteer launch parameters. Look for profile path by executing chrome://version in your browser. Doing this, puppeteer executed itself in the same chrome window that I am currently using.

pptr.launch({headless: false,
  executablePath: '[insert executable path here]',
  userDataDir: '[insert profile path or user directory path here]'}).then(async browser => {
});

This works perfectly fine with one little thing:
when you take the profile path from
chrome://version/
make sure to remove "Default" from the path's end

@Andriy-Kulak
Copy link

@matheuscch

Try this

  1. create a new chrome shortcut on your desktop and add --remote-debugging-port=9222 to the target.
  2. open it using the just created shortcut and go to http://127.0.0.1:9222/json/version

This json should give you the webSocketDebuggerUrl, which you case use to connect to the instance. If I'm not wrong it should be something like

await puppeteer.connect({browserWSEndpoint: webSocketDebuggerUrl})

If anyone ever gets here, this still works but you need to replace localhost with 127.0.0.1 in webSocketDebuggerUrl when using newer versions of node.js. Reference this #8873

@D210000
Copy link

D210000 commented May 27, 2024

@matheuscch

Try this

  1. create a new chrome shortcut on your desktop and add --remote-debugging-port=9222 to the target.
  2. open it using the just created shortcut and go to http://127.0.0.1:9222/json/version

This json should give you the webSocketDebuggerUrl, which you case use to connect to the instance. If I'm not wrong it should be something like

await puppeteer.connect({browserWSEndpoint: webSocketDebuggerUrl})

If anyone ever gets here, this still works but you need to replace localhost with 127.0.0.1 in webSocketDebuggerUrl when using newer versions of node.js. Reference this #8873

Hey I still not able to connect webSocketdebugger cause site not open at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests