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

Html Agility Pack 处理通配符

上一篇:C#项目里每个文件的含义


下一篇:PHP系统类函数