Skip to content

Instantly share code, notes, and snippets.

@axeldelafosse
Created April 3, 2022 13:31
Show Gist options
  • Save axeldelafosse/816b9e2856b358c4b8a29ced031f99b7 to your computer and use it in GitHub Desktop.
Save axeldelafosse/816b9e2856b358c4b8a29ced031f99b7 to your computer and use it in GitHub Desktop.
Scrape your Google Play Console cookies with Puppeteer 🍪
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
async function scrapeGooglePlayCookies() {
console.log('Scraping Google Play cookies...');
const browser = await puppeteer.use(StealthPlugin()).launch({
headless: false,
executablePath: process.env.PUPPETEER_EXEC_PATH,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
],
});
const page = await browser.newPage();
await page.goto(
'https://accounts.google.com/signin/v2/identifier?service=androiddeveloper&passive=true&continue=https%3A%2F%2Fplay.google.com%2Fconsole%2Fdeveloper%2F&flowName=GlifWebSignIn&flowEntry=ServiceLogin',
);
await page.waitForSelector('input[type="email"]');
await page.type('input[type="email"]', process.env.GOOGLE_PLAY_EMAIL);
await Promise.all([
await page.keyboard.press('Enter'),
page.waitForNavigation(),
]);
await page.waitForSelector('input[type="password"]', { visible: true });
await page.type('input[type="password"]', process.env.GOOGLE_PLAY_PASSWORD);
await Promise.all([
await page.keyboard.press('Enter'),
page.waitForNavigation(),
]);
await page.waitForFunction(
'document.querySelector("body").innerText.includes("Choose developer account")',
);
const cookies = await page.cookies();
cookies.map((cookie) => {
console.log(cookie);
});
await browser.close();
console.log('Done!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment