Skip to content

Instantly share code, notes, and snippets.

@gahabeen
Created January 30, 2017 14:35
Show Gist options
  • Save gahabeen/e1e79df780ca1d5c6580083f947aa23d to your computer and use it in GitHub Desktop.
Save gahabeen/e1e79df780ca1d5c6580083f947aa23d to your computer and use it in GitHub Desktop.
let cheerio = require('cheerio');
let jsonframe = require('jsonframe-cheerio');
request('https://www.growthhacking.fr', function (error, response, html) {
if (!error && response.statusCode == 200) {
let $ = cheerio.load('https://www.growthhacking.fr');
jsonframe($); // initializes the plugin
var frame = {
"post": { // setting the parent item as "companies"
"selector": ".topic-list", // defines the elements to search for
"data": [{
"name": ".title",
"description": "",
"url": {
"selector": ".title",
"attr": "href",
},
}] // "data": [{}] defines a list of items
},
};
var postsList = $('.topic-list').scrape(frame);
console.log(postsList);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment