You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constrequest=require('superagent')constsuperagentCheerio=require('superagent-cheerio')constres=awaitrequest.get('https://www.google.co.uk').use(superagentCheerio())console.log(res.$('h1').text())// or promisesrequest.get('https://www.google.co.uk').use(superagentCheerio()).then(res=>{console.log(res.$('h1').text())})
Usage for lots of requests
constrequest=require('superagent')constsuperagentCheerio=require('superagent-cheerio')constagent=request.agent().use(superagentCheerio())constres=awaitagent.get('https://www.google.co.uk')console.log(res.$('h1').text())// or promisesagent.get('https://www.google.co.uk').then(res=>{console.log(res.$('h1').text())})
Usage with cheerio load method options
constrequest=require('superagent')constsuperagentCheerio=require('superagent-cheerio')constres=awaitrequest.get('https://www.google.co.uk').use(superagentCheerio({xmlMode: true}))console.log(res.$('h1').text())// or promisesrequest.get('https://www.google.co.uk').use(superagentCheerio({xmlMode: true})).then(res=>{console.log(res.$('h1').text())})
Running tests
Install dependencies:
$ npm install
Run tests:
$ npm test
License
MIT
About
Simple extension for SuperAgent that adds cheerio to html responses