Data Scraping in Node.js 101

Gathering data without those pesky databases

Danny Denenberg
Sep 3, 2019 · 4 min read
Image for post
Image for post
Photo by Markus Spiske on Unsplash
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
$ npm -v # should be 6.0.0 or higher $ node -v # should be 9.0.0 or higher
$ mkdir Web-Scraping-101 && cd Web-Scraping-101 
$ npm init # go through all defaults
$ npm i puppeteer # the google npm scraping package
$ tsc --init # initialize typescript
$ npm i @types/puppeteer # type declarations
Image for post
Image for post
$ touch app.ts
console.log("Twitter, here we come");
document.querySelector("#react-root > div > div > div > main > div > div.css-1dbjc4n.r-aqfbo4.r-1niwhzg.r-16y2uox > div > div.css-1dbjc4n.r-14lw9ot.r-1tlfku8.r-1ljd8xs.r-13l2t4g.r-1phboty.r-1jgb5lz.r-1ye8kvj.r-13qz1uu.r-184en5c > div > div > div.css-1dbjc4n.r-1jgb5lz.r-1ye8kvj.r-6337vo.r-13qz1uu > div > section > div > div > div");
// the above returns the div for the middle column twitter feed
Image for post
Image for post
console.log(dimensions.sources);

Resources

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store