Created
January 22, 2018 17:19
-
-
Save sputnick-dev/c82166195290c636e4abaea34ea42cf6 to your computer and use it in GitHub Desktop.
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'); | |
let scrape = async () => { | |
const browser = await puppeteer.launch({headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']}); | |
const page = await browser.newPage(); | |
await page.goto('https://99bitcoins.com/bitcoin-rich-list-top100/#addresses'); | |
await page.waitFor(1000); | |
const result = await page.evaluate(() => { | |
var obj = {}; | |
var data = document.querySelectorAll('table.t99btc-rich-list tr'); | |
for (var i = 1; i<=100; i++) { | |
obj[i] = { | |
"hash": data[i].querySelector('td > a').innerText, | |
"balance": data[i].querySelector('td:nth-of-type(3)').innerText | |
} | |
} | |
return obj; | |
}); | |
browser.close(); | |
return result; | |
}; | |
scrape().then((value) => { | |
console.log(JSON.stringify(value, null, 4)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment