opened
Tigerball890
username_0
Can you look into this? A lot of things I want to use with cheerio use this type of selector, and Cheerio does not support it.
Support :nth-child()
issue
created
watson
username_1
@username_0 I thought that `nth-child()` was supported in cheerio natively? At least it seems to be according to this issue: https://github.com/cheeriojs/cheerio/issues/143
comment
created
Tigerball890
username_0
I'll have to look further. I used cheerio for webscraping once, and it nullified the results with ``nth-child()``
comment
created
watson
username_1
@username_0 did you ever get this to work natively?
comment
created
Twisterking
username_2
Same problem here ... using cheerio to "improve" the horrible wikipedia "API". Trying to get the first p-tag of the wikipedia article and sometimes actually the second p-tag contains the useful information.
`$('p:nth-child(1)').not('table p');` returns the useless text (which is right in that case), so I want the second p-tag. `$('p:nth-child(2)').not('table p');` or even `$('p:nth-child(3)').not('table p');` all return `null`. Any ideas on this?
(here is the wikipedia article: https://de.wikipedia.org/wiki/Grambach)
comment
created
watson
username_1
@username_0:

I just tried to run the following using cheerio directly:

```js
var cheerio = require('cheerio')
var html = '<div><span>a</span><span>b</span><span>c</span></div>'
var $ = cheerio.load(html)
var str = $('div>span:nth-child(2)').text()
console.log(str)
```

This logged the string `b` as expected, so `nth-child()` is indeed supported by cheerio.


@username_2: 

Are you using the `cheerioAdv.wrap` functionality?
comment