node-osmosis icon indicating copy to clipboard operation
node-osmosis copied to clipboard

Getting data from list

Open ZigaVukcevicDev opened this issue 8 years ago • 2 comments

Hi,

here is html sample which I'd like to scrape.

<div class="items">
    <div class="item">
        <div class="name">John</div>
        <img src="john.jpg" />
    </div>
    <div class="item">
        <div class="name">Ana</div>
        <img src="ana.jpg" />
    </div>
</div>

With my code I keep getting into strange loops.

    .get('http://someUrl.com')
    .log(console.log)
    .find('.name')
    .set('name')
    ...

How would I get this data? Thank you in advance.

PS: If there would be any more tutorials, that would be awesome.

ZigaVukcevicDev avatar Feb 10 '17 07:02 ZigaVukcevicDev

Append .data() to your code.

...
.data(function (item) {
  console.log(item.name);
});

rchipka avatar Feb 10 '17 17:02 rchipka

Ok, this sample works. But how I could also get image?

ZigaVukcevicDev avatar Feb 11 '17 07:02 ZigaVukcevicDev