medialab/artoo

Multiple selectors question

Opened this issue · 3 comments

Hello,

I'm trying to use Artoo.js and I see it's really promising scraping library in JavaScript world! Thanks for this a great library.

My problem is, I'm using artoo.ajaxSpider with scrap parameter on it, the problem is I'm using sometimes multiple selectors to get one value, as the layout of the requested pages are different so the selectors are! If I added all needed selectors in iterator them I'll got many return objects without knowing the returned value for any of the selector!

If I needed many selectors to be iterated on to get many values on the requested page, how to know the returned value for which selector, is there any returned mapping array?

Thanks!

Hello @MohammadAlBanna. If you pass a function to treat the selected data in your scrape definition, you'll be able to use $(this) and be able to do thing related to it, for instance check if the element has specific classes etc. or is valid for a certain sub-selection.

Hello @Yomguithereal and thank you very much for your response. Yes, I remember I saw this somewhere in the documentation but when I wanted to get back I forgot where, it seems also is not documented in artoo.scrape of how to use iterator as a function. But I think I got your thought, getting the current selector using $(this) in the callback is a good idea.

Kind Regards,
Mohammad AlBanna

Don't hesitate to ask if you need more specific examples with some code.