I'm trying to automate a task of mine with Node.js, trying to find the winning numbers on the local car lotto.
When I'm trying to parse the results, I get nothing back.
here is my try:
const rp = require('request-promise');
const $ = require('cheerio');
const url = 'https://www.otpbank.hu/portal/hu/Megtakaritas/ForintBetetek/Gepkocsinyeremeny';
rp(url)
.then(function(html) {
console.log($('.list-item list-item--primary ul li', html).text());
})
.catch(function(err) {
//handle error
});
Since the 'list-item--primary' is already li
element, try:
const rp = require('request-promise');
const cheerio = require('cheerio');
const url = 'https://www.otpbank.hu/portal/hu/Megtakaritas/ForintBetetek/Gepkocsinyeremeny';
rp(url)
.then(function(html) {
const $ = cheerio.load(html);
let data = [];
$('.list-item--primary').map((i,elm) => {
console.log(elm.innerText);
});
})
.catch(function(err) {
//handle error
});
works great, thanks you, is there any way just to get the text out of the individual li elements?
Glad to help. What do you get in return?
i'd like to get the numbers of the list-item list-item--primary class li elements, such as "10 8004923 Toyota Yaris 1,0 Active 5 ajtós"
I updated my answer, try again.
marked your answer as result, thank you for your time, happy holidays to you!