matthewmueller / x-ray

The next web scraper. See through the <html> noise.
MIT License
5.87k stars 349 forks source link

Selecting multiple tags with the same className? #271

Closed AlFalahTaieb closed 5 years ago

AlFalahTaieb commented 7 years ago

Using this syntax:

x('http://www.viadeo.com/fr/company/unicef', 
    '.page-content',
    [{
    img:'img@src',
    bio:'.pan-desc-description',

    org:'.pan-desc-footer-element @element-value',
    link: '.element-value a@href',
    **twitter:'.element-value a@href'** // I get the previous link not the twitter one 

}]).write('result.json')

There are multiple items within the website with that specific classname, but it only returns the first one. Is there a way to grab all of them and maybe I can do a .limit with that return? I apologize if it's in the documentation, I've read through it twice and it looks like it's not explicitly said anywhere.

Thank you so much for this module, it's so awesome. Taieb

lathropd commented 5 years ago

Try using the :nth-of-type pseudo-selector.