Created
September 8, 2019 13:42
-
-
Save av/866a835842d83d16149072fbea20fe73 to your computer and use it in GitHub Desktop.
Pub.dev package name distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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