Created
January 30, 2017 14:35
-
-
Save gahabeen/e1e79df780ca1d5c6580083f947aa23d 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
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