How to access output from Node.js' request module -
Several tutorials that But what if I want to process the output during script execution? How can I use the output or send it to the call function? I can definitely load You can wrap a request in a function that Then assign it to request and
cheerio In these tutorials, they send the output to the console or send the DOM to the file as an example with
fs .
request (link, function, resp, html) {if (return) return console.error (err) var $ = cheerio.load (html), img = $ ('# img_wrapper' ). Data ('src'); Console.log (img);}). Pipe (fs.createWriteStream ('img_link.txt'));
img_link.txt and get information from there, but it will be expensive and will not make sense.
html
function (link, callback) {request (link, work (error, im, body) {callback (mistake, body);}); });
export and use it in any other module.
Comments
Post a Comment