Created
October 18, 2020 16:50
-
-
Save isNan909/f3d4cc400b279849fc263e0ff1c94a7a to your computer and use it in GitHub Desktop.
Node Scrapping Example
This file contains hidden or 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 SCRAPE_URL = `https://coincodex.com/`; | |
| (async () => { | |
| const browser = await puppeteer.launch({ headless: false }); | |
| const page = await browser.newPage(); | |
| await page.goto(SCRAPE_URL); | |
| await page.screenshot({ path: "sample.png" }); | |
| const coining = await page.evaluate(() => | |
| Array.from(document.querySelectorAll("table tr.coin.ng-star-inserted")).map( | |
| (table) => ({ | |
| coinName: table.querySelector(".full-name").innerText.trim(), | |
| coinPrice: table.querySelector(".currency").innerText.trim(), | |
| }) | |
| ) | |
| ); | |
| console.log(coining); | |
| await browser.close(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment