blob: d46a44f1a9d17aec12d2065bf0e4f3b487191b09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var cheerio = require('cheerio');
var Promise = require('../../utils/promise');
/**
Apply a list of operations to a page and
output the new page.
@param {Page}
@param {List|Array<Transformation>}
@return {Promise<Page>}
*/
function modifyHTML(page, operations) {
var html = page.getContent();
var $ = cheerio.load(html);
return Promise.forEach(operations, function(op) {
op($);
})
.then(function(resultHTML) {
return page.set('content', resultHTML);
});
}
module.exports = modifyHTML;
|