jquery-scrape
Use jQuery as your selection engine on an HTTP request's response.
Installation
npm i jquery-scrape -S
Usage
jquery-scrape is a convenience wrapper for request and cheerio. With almost no code, you can make an HTTP request and get back a jQuery selection engine. Here's a working example that you can run in your terminal:
"https://www.example.com/" { // Get the inner HTML of the DOM's body element. const html = ; console; // Get the href attribute of an anchor tag. const href = ; console; // Traverse through each paragraph... ; };
Or suppose you want to scrape a table and output its result as JSON. Suppose the table is structured like the one in this repo's test directory:
Number Value 1 Foo 2 Bar
Scrape it like so:
"https://raw.githubusercontent.com/HarryStevens/jquery-scrape/master/test/test.html" { let columns = ; ; let data = ; const rows = ; console; rows; console; fs; };
Tests
npm test