32 lines
729 B
JavaScript
32 lines
729 B
JavaScript
const cheerio = require('cheerio');
|
|
|
|
const fs = require('fs');
|
|
const jsonfile = require('jsonfile');
|
|
|
|
const logger = require('log4js').getLogger('history');
|
|
|
|
logger.level = 'debug';
|
|
|
|
function run() {
|
|
const output = [];
|
|
const h = fs.readFileSync('tests/data/hist001.html');
|
|
|
|
const $ = cheerio.load(h);
|
|
const bigBlock = $('#chm-exhibit-content > article > div > div');
|
|
|
|
const rows = $(bigBlock).find('div.chm-exhibit-timeline-decade-row');
|
|
|
|
rows.each((i, item) => {
|
|
const title = $(item).find('.chm-tdih-entry-title').text();
|
|
const content = $(item).find('.chm-tdih-entry-content').text();
|
|
|
|
logger.debug(title);
|
|
|
|
output.push({ title, content });
|
|
});
|
|
|
|
logger.debug(JSON.stringify(output));
|
|
}
|
|
|
|
run();
|