Creates a stream that parses a sequence of strings into a document.
The stream is a Writable stream that accepts strings. When the stream is finished, the callback is called with the loaded document.
Writable
The options to pass to Cheerio.
The callback to call when the stream is finished.
The writable stream.
import * as cheerio from 'cheerio';import * as fs from 'fs';const writeStream = cheerio.stringStream({}, (err, $) => { if (err) { // Handle error } console.log($('h1').text()); // Output: Hello, world!});fs.createReadStream('my-document.html', { encoding: 'utf8' }).pipe( writeStream,); Copy
import * as cheerio from 'cheerio';import * as fs from 'fs';const writeStream = cheerio.stringStream({}, (err, $) => { if (err) { // Handle error } console.log($('h1').text()); // Output: Hello, world!});fs.createReadStream('my-document.html', { encoding: 'utf8' }).pipe( writeStream,);
Creates a stream that parses a sequence of strings into a document.
The stream is a
Writablestream that accepts strings. When the stream is finished, the callback is called with the loaded document.