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
let cheerio = require('cheerio'); | |
let jsonframe = require('jsonframe-cheerio'); | |
let $ = cheerio.load('our html page url here'); | |
jsonframe($); // initializes the plugin | |
var frame = { | |
"companies": { // setting the parent item as "companies" | |
"selector": ".item", // defines the elements to search for | |
"data": [{ // "data": [{}] defines a list of items |
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
let cheerio = require('cheerio') | |
let $ = cheerio.load('our html page url here') | |
var companiesList = []; | |
// For each .item, we add all the structure of a company to the companiesList array | |
// Don't try to understand what follows because we will do it differently. | |
$('.list.items .item').each(function(index, element){ | |
companiesList[index] = {}; | |
var header = $(element).find('.header'); |
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
company : .list.items .item | |
|_ name : .header [itemprop=name] | |
|_ description : .header [rel=description] | |
|_ url : .header [itemprop=name] a | |
|_ contact : .contact | |
|_ telephone : [itemprop=telephone] | |
|_ employee | |
|_ name : [itemprop=employeeName] | |
|_ jobTitle : [itemprop=employeeJobTitle] | |
|_ email : [itemprop=email] |
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
company | |
|_ name | |
|_ description | |
|_ url | |
|_ contact | |
|_ telephone | |
|_ employee | |
|_ name | |
|_ jobTitle | |
|_ email |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
</head> | |
<body> | |
<!-- Data we want to scrape starts here --> | |
<div class="list items"> | |
<div class="item"> | |
<div class="header"> |
NewerOlder