码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-10-21 15:58:40      阅读:418      评论:0      收藏:0      [点我收藏+]

标签:tor   put   gil   scrapy   aging   arp   解析   direct   arc   

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解析的痛苦

标签:tor   put   gil   scrapy   aging   arp   解析   direct   arc   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!