Html Agility Pack 处理通配符

Html Agility Pack 处理通配符


let doc = new HtmlAgilityPack.HtmlDocument()
doc.LoadHtml( html )


========


let url = "http://Site.site.site"


let html = new HtmlAgilityPack.HtmlWeb()
let doc0 = html.Load  ( url ) 
html.OverrideEncoding <- doc0.Encoding
let doc = html.Load  ( url ) 








doc.DocumentNode.SelectNodes("//input")
|> Seq.map (fun i -> i.OuterHtml)
|> Seq.iter (printfn "%s")


<input id="tb_user" class="textbox_sty2" ...>
<input id="tb_pass" class="textbox_sty2" ...>
<input id="bt_ok" ...>
<input id="bt_cancle" ...>
<input type="hidden" name="__EVENTTARGET">
<input type="hidden" name="__EVENTARGUMENT">




doc.DocumentNode.SelectNodes("//input[contains(@id, ‘bt‘)]")
|> Seq.map (fun i -> i.OuterHtml)
|> Seq.iter (printfn "%s")


<input id="bt_ok" ...>
<input id="bt_cancle" ...>




doc.DocumentNode.SelectNodes("//input[contains(@name, ‘__‘)]")
|> Seq.map (fun i -> i.OuterHtml)
|> Seq.iter (printfn "%s")


<input type="hidden" name="__EVENTTARGET">
<input type="hidden" name="__EVENTARGUMENT">


doc.DocumentNode.SelectNodes("//input[starts-with(@id, ‘tb‘)]")
|> Seq.map (fun i -> i.OuterHtml)
|> Seq.iter (printfn "%s")


<input id="tb_user" class="textbox_sty2" ...>
<input id="tb_pass" class="textbox_sty2" ...>




http://www.w3school.com.cn/xpath/xpath_functions.asp

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。