0

I am attempting to build a web scraper that will ultimately list an array of properties from this website called landa. Learning Cheerio to do this, and I seem to have been able to create an array of 'divs' but when input a class like '.PropertyItem_propertyItem__Fla4I' it returns an empty array.

This returns a console.log of all the divs in the html

const PORT = 8000
const axios = require('axios')
const cheerio = require('cheerio')
const express = require('express')

const app = express()

const url = 'https://landa.app/m/feed'

axios(url)
    .then(response => {
        const html = response.data
        const $ = cheerio.load(html)
        const properties = [];

        $('div').each(function (i, elem) {
            properties[i] = $(this).text();
        })

        console.log(properties)

    }).catch(err => console.log(err))
    
app.listen(PORT, () => console.log("server running"))

But this doesn't return a console.log of '.PropertyItem_propertyItem__Fla4I' class items like I would expect. It just returns an empty array.

const PORT = 8000
const axios = require('axios')
const cheerio = require('cheerio')
const express = require('express')

const app = express()

const url = 'https://landa.app/m/feed'

axios(url)
    .then(response => {
        const html = response.data
        const $ = cheerio.load(html)
        const properties = [];

        $('.PropertyItem_propertyItem__Fla4I').each(function (i, elem) {
            properties[i] = $(this).text();
        })

        console.log(properties)

    }).catch(err => console.log(err))
    
app.listen(PORT, () => console.log("server running"))

I am lost here. Appreciate anyone who can help me learn. Thanks!

nbbowen
  • 3
  • 3
  • The app is [JS-driven](https://stackoverflow.com/questions/28739098/how-can-i-scrape-pages-with-dynamic-content-using-node-js). Consider Puppeteer. – ggorlen Feb 25 '23 at 01:22

0 Answers0