last day (15 days later) » 

9:02 AM
2
Q: How to get image url by cheerio?

Hammad ul HasanI want to get image urls by scrapping data by cheerio from a slider but can able to do this tried a lot but can found a solution here is my code below const retURL = a.find('.gallery-carousel').find('img').attr('src') .map(function(){ let image= $(this).attr('src'); console.log(image,...

 
did you get a solution for your issue?
 
@JayakumarThangavel not at all
 
can you please add HTML code also
 
@JayakumarThangavel which html code i have added inspect elements and code
 
var imageurl = $('.gallery-carousel__image-touchable').find('img').attr('sr‌​c');
var imageurl = $('.slide button').find('img').attr('src');
 
9:02 AM
@JayakumarThangavel failed , return undefined
@JayakumarThangavel should we use map function ?
 
Map function used when an array of result set but in this case, there is string return type so I believe it's not required
 
i think so there is a array of results
 
ok can you place your HTML code so I can verify it? currently i manipulated using sample data.
 
because there is multiple images used inside the slider
sure which code inspect element ?
 
yes i got it. Please provide the html for the slider
we have to get based on the slider class
let me fix shortly
 
9:07 AM
Yes please i will be very thankful to you
here is the link of web that i am using for scrapping i want to scrap the images that are using in the slider
 
ok
var listItems = $(".gallery-carousel ul li");
listItems.each(function(idx, li) {
let image= $(li).find('img').attr('src');
console.log(image);
// and the rest of your code
});
based on the above code, you can get list of items inside the ul tag
 
its working ?
 
yes i updated answer with sample
please run over there
 
sure let me try this please wait
 
9:21 AM
can you please show me your output ?
its return me nothing
 var listItems = $(".gallery-carousel ul li");
    listItems.each(function (idx, li) {
        let image = $(li).find('img').attr('src');
        console.log(image);
        // and the rest of your code
    });
    console.log(listItems)
console.log(listItems) consoling starts and never stops dont what is consloed by the .each function and li
 
ok
in your website, carousal has 5 images
i have updated based on our screen
 
9:38 AM
yeah its looks nice but why its not works for me
what should i have to return listitems or image ?
?
file that you sent me return listItems.length = 0
 
Please check now and verify it in console
 
by using this code ?
 
9:55 AM
what is this ?
console.log(arr.join(',')) this line not consoling
now which code is working fine for you ?
?
 
10:36 AM
var arr=$(".slider-wrapper ul li").map(function( a ) {
return $(this).find('img').attr('src');
}).get();
it gives you array of result
 
ok thanks a lot bro let me try
 
its return empty array
are you there ?
 
yes something wrong here because of cheerio js
you are sharing code of nodejs service file right
Is it possible to access our html page content in that service file?
 
10:54 AM
Amm i am giving the url of that page to cheerio
dont know how to access html page content directly in that service file
what are you using instead of cheerio ?
 
11:23 AM
$('.slider-wrapper').html()
I believe that the place you are looking for HTML does not have content
 
sorry can't understand what you are saying
$('.slider-wrapper').html() how to use this ?
 

last day (15 days later) »