rflechner/ScrapySharp

suggest: support selector like ` :scope > a`

charliefr opened this issue · 1 comments

environment

  • netcoreapp2.2
  • dotnet add package ScrapySharp --version 3.0.0

details

invalid selector :scope > a

example

<div id="node">
some text <a>link</a> 
<span>span</span> some text <br/>
<p><a>link</a> </p>
</div>

I want select like &>a, or #node>a,but use (HtmlNode node).CssSelect("selector")

HtmlNode node = ....
node.CssSelect(":scope > a")

same like .tit>a:nth-child(2) ,
I can use LINQ like
var link= tit.ChildNodes.Where((e, idx) => e.Name == "a" && idx == 1).FirstOrDefault()
when use the selector, if can't find the element, easy way to throw exception and include the selector > but use linq need add more messages .

thanks

ScrapySharp is simple and powerful tools, this is functional recommendation,
Thank all the participants for their great work.

I would like to see support for :nth-child selectors also. Running into a problem right now where I need to use that selector.