Trying to web scraping with nodeJS and cheerIO

I’m trying to use web scraping with nodeJS and cheerIO, but I’m not able to get the HTML content.
I tried with .html() function and is not resolving it, it says that is not a function.

This is the code where I’m trying to obtain the data from the web page:

const cheerio = require('cheerio');
const request = require('request');

const test_data = {}

test_data.getHouses = async () => {
    const $doc = await request({
        uri: '',
        transform: body => cheerio.load(body)

This is the request object output.

Request {
  _events: [Object: null prototype] { pipe: [Function] },
  _eventsCount: 1,
  _maxListeners: undefined,
  uri: Url {
    protocol: 'https:',
    slashes: true,
    auth: null,
    host: '',
    port: 443,
    hostname: '',
    hash: null,
    search: '?tab_id=all_tab&refinement_paths%5B%5D=%2Fhomes&query=San%20Sebasti%C3%A1n%2C%20Spain&place_id=ChIJFf5oO_6vUQ0RSUaGlFnFPuQ&source=structured_search_input_header&search_type=search_query',
    query: 'tab_id=all_tab&refinement_paths%5B%5D=%2Fhomes&query=San%20Sebasti%C3%A1n%2C%20Spain&place_id=ChIJFf5oO_6vUQ0RSUaGlFnFPuQ&source=structured_search_input_header&search_type=search_query',
    pathname: '/s/San-Sebasti%C3%A1n--Spain/homes',
    path: '/s/San-Sebasti%C3%A1n--Spain/homes?tab_id=all_tab&refinement_paths%5B%5D=%2Fhomes&query=San%20Sebasti%C3%A1n%2C%20Spain&place_id=ChIJFf5oO_6vUQ0RSUaGlFnFPuQ&source=structured_search_input_header&search_type=search_query',
    href: ''
  transform: [Function: transform],
  readable: true,
  writable: true,
  _qs: Querystring {
    request: [Circular],
    lib: { formats: [Object], parse: [Function], stringify: [Function] },
    useQuerystring: undefined,
    parseOptions: {},
    stringifyOptions: {}

Thanks for reading!

5 thoughts on “Trying to web scraping with nodeJS and cheerIO”

Leave a Comment