matthewmueller / x-ray

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

Selector not really working #150

Closed eldyvoon closed 8 years ago

eldyvoon commented 8 years ago

Subject of the issue

Weak selectors issue

Steps to reproduce

run below example

x('http://search.azlyrics.com/search.php?q=tired+adele', {
              link: x('body > div.container.main-page > div > div > div > table > tbody > tr:nth-child(1) > td > a')
            })(function(err, data){
                console.log(data);
            });

Expected behaviour

Get the link.

Actual behaviour

I got empty object.

eldyvoon commented 8 years ago

I do this link: x('body > div.container.main-page > div > div > div > table > tr:nth-child(1) > td > a@href') found it's working fine, hmm it doesn't recognize tbody?

Kikobeats commented 8 years ago

I detected that selector doesn't work fine with deep levels, but I'm not sure what is happening.

I think that is not related directly with x-ray, maybe with the parser used by x-ray, but definitely need the light of @matthewmueller.

ageorgios commented 8 years ago

Try to omit "tbody" completely, worked for me

Kikobeats commented 8 years ago

yes, I remember a similar problem with table tags

webholics commented 8 years ago

I have the same problem.

mcornella commented 8 years ago

You should try looking at the actual source code of the web page, as DevTools will show the proper DOM even if it is "malformed".

mcornella commented 8 years ago

Yep, see, no tbody on the actual source: captura de pantalla de 2016-04-19 23-10-48

mcornella commented 8 years ago

This is solved @Kikobeats.