const cheerio = require('cheerio');
const request = require('sync-request');
const fs = require('fs');
var res = request('GET', 'https://edition.cnn.com/');
console.log(res.getBody())
This is my code. I want to get HTML code of https://edition.cnn.com/. But it returning following:
<Buffer 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 3c 68 74 6d 6c 20 63 6c 61 73 73 3d 22 6e 6f 2d 6a 73 22 3e 3c 68 65 61 64 3e 3c 6d 65 74 61 20 63 6f 6e ... >
You are receiving a buffer currently, you need to convert it to string. Use this -
console.log(res.getBody().toString())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With