Answer the question
In order to leave comments, you need to log in
How to properly parse a DOM element using Cheerio?
It is necessary to pull out all the data from the card with the products-grid__col col-12 col-md-6 col-xl-4 class
. I can’t set the path to any of the DOM elements, how to get at least the name with the compact-card__name class. I tried to take it on the site through querySelector, or children, but in cheerio it gives an error
var cheerio = require('cheerio');
var request = require('request');
var fs = require('fs');
var URL = 'https://spb.xiacom.ru/catalog/smartfony-xiaomi/?PAGEN_1=1&ajax=catalog.list';
var results = [];
request(URL, function(err, res) {
if (err) throw err;
var $ = cheerio.load(res.body);
console.log($(".products-grid__col")[0])
});
Answer the question
In order to leave comments, you need to log in
1) Get jqueryinject chrome extension and work with it.
2) request should be an asynchronous function and the result should wait for await of course how will you get it if your function works before it receives a response
3) And what do you want to return in this request, probably use the content there
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question