Skip to content

Instantly share code, notes, and snippets.

@av
Created September 8, 2019 13:42
Show Gist options
  • Save av/866a835842d83d16149072fbea20fe73 to your computer and use it in GitHub Desktop.
Save av/866a835842d83d16149072fbea20fe73 to your computer and use it in GitHub Desktop.
Pub.dev package name distribution
const puppeteer = require('puppeteer');
const alphabet = 'poiuytrewqlkjhgfdsamnbvcxz'.split('');
(async () => {
let results = {};
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage();
await page.setViewport({ width: 1024, height: 768 });
for (let char of alphabet) {
await page.goto(`https://pub.dev/packages?q=package%3A${char}`);
const el = await page.$('.package-count span');
const count = await (await el.getProperty('textContent')).jsonValue();
results[char] = parseInt(count);
await page.screenshot({path: `pub/${char}.png`});
}
console.log(JSON.stringify(results, null, 2));
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment