首页 > Web开发 > 详细

HTML Agility Pack 搭配 ScrapySharp,彻底解除Html解析的痛苦

时间:2016-10-21 15:56:34      阅读:253      评论:0      收藏:0      [点我收藏+]

var divs = html.CssSelect("div");  //all div elements
var nodes = html.CssSelect("div.content"); //all div elements with css class ‘content’
var nodes = html.CssSelect("div.widget.monthlist"); //all div elements with the both css class
var nodes = html.CssSelect("#postPaging"); //all HTML elements with the id postPaging
var nodes = html.CssSelect("div#postPaging.testClass"); // all HTML elements with the id postPaging and css class testClass
var nodes = html.CssSelect("div.content > p.para"); //p elements who are direct children of div elements with css class ‘content’
var nodes = html.CssSelect("input[type=text].login"); // textbox with css class login
We can also select ancestors of elements:
var nodes = html.CssSelect("p.para").CssSelectAncestors("div.content > div.widget");

参考资料:

http://www.cnblogs.com/shanyou/archive/2012/05/27/2520603.html

HTML Agility Pack 搭配 ScrapySharp,彻底解除Html解析的痛苦

原文:http://www.cnblogs.com/lihuali/p/5984598.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!