大神博客:http://www.cnblogs.com/Ivony/p/3447536.html
项目地址:https://github.com/Ivony/Jumony
1、安装Jumony包
在Nuget搜索框中输入 "Jumony",安装 Jumony Core 。
2、引入命名空间
using Ivony.Html;
using Ivony.Html.Parser;
3、开整
var parser = new JumonyParser();
var document = parser.LoadDocument( "http://www.cnblogs.com/" );
var elements = document.Find( "#post_list > .post_item" );
foreach ( var e in elements )
{
Console.WriteLine( "title: {0}", e.FindFirst( "h3 > a" ).InnerText() );
Console.WriteLine( "link: {0}", e.FindFirst( "h3 > a" ).Attribute( "href" ).Value() );
Console.WriteLine( "votes: {0}", e.FindFirst( ".diggnum" ).InnerText() );
Console.WriteLine( "author: {0}", e.FindFirst( ".post_item_foot a.lightblue" ).InnerText() );
Console.WriteLine( new string( '-', 30 ) );
}
4、结果:
title: [android游戏开发初学]简单的游戏引擎
link: http://www.cnblogs.com/boliu/p/3307624.html
votes: 1
author: boliu
------------------------------
title: 由JS函数返回值引发的一场”血案"
link: http://www.cnblogs.com/feng-c-x/p/3307560.html
votes: 0
author: Flx
------------------------------
title: IceMx.Mvc 我的js MVC 框架六、完善植物大战僵尸(向日葵登场)
link: http://www.cnblogs.com/ajimidan/p/3307544.html
votes: 1
author: 飞翔吧菜鸟
------------------------------
title: Redis安装介绍
link: http://www.cnblogs.com/fuhongxue2011/p/3307528.html
votes: 0
author: 傅红雪2011
------------------------------
title: 小学徒博客索引
link: http://www.cnblogs.com/xiaoxuetu/p/3297555.html
votes: 0
author: 小学徒V
------------------------------
title: JVM源码---教你傻瓜式编译openjdk7(JAVA虚拟机爱好者必看)
link: http://www.cnblogs.com/zuoxiaolong/p/jvm10.html
votes: 0
author: 左潇龙
------------------------------
title: Moon.Orm 5.0及之前版本的开源计划
link: http://www.cnblogs.com/humble/p/3307388.html
votes: 1
author: [秦时明月]
------------------------------
title: touch事件分发
link: http://www.cnblogs.com/ctaodream/p/3307386.html
votes: 0
author: ctaodream
------------------------------
title: Ubuntu下安装qq方法及疑难问题解决
link: http://www.cnblogs.com/lanxuezaipiao/p/3307381.html
votes: 0
author: Alexia(minmin)
------------------------------
title: 讲讲Linq to SQL映射(基础篇)
link: http://www.cnblogs.com/flowwind/p/3307373.html
votes: 1
author: flowbywind
------------------------------
title: 关于android内存泄漏的研究
link: http://www.cnblogs.com/huyong123/p/3307372.html
votes: 0
author: 一只奋斗的猿
------------------------------
title: 云计算之路-试用Azure:如何建立虚拟机之间的内网连接
link: http://www.cnblogs.com/cmt/p/3305983.html
votes: 4
author: 博客园团队
------------------------------
title: 初试weka数据挖掘
link: http://www.cnblogs.com/hxsyl/p/3307343.html
votes: 4
author: DM张朋飞
------------------------------
title: 十三种基于直方图的图像全局二值化算法原理、实现、代码及效果。
link: http://www.cnblogs.com/Imageshop/p/3307308.html
votes: 3
author: Imageshop
------------------------------
title: 算法:字符串消除问题的数学证明
link: http://www.cnblogs.com/grenet/p/3300591.html
votes: 0
author: 万仓一黍
------------------------------
title: 【吐槽】VS2012的安装项目只能用InstallShield Limited Edition[附资源下载]
link: http://www.cnblogs.com/asxinyu/p/3306992.html
votes: 2
author: asxinyu
------------------------------
title: JS面向对象思想(OOP)
link: http://www.cnblogs.com/BABLOVE/p/3307038.html
votes: 0
author: 如梦不是梦
------------------------------
title: 使用avalon 实现一个序列号功能
link: http://www.cnblogs.com/rubylouvre/p/3306344.html
votes: 2
author: 司徒正美
------------------------------
title: 后缀数组
link: http://www.cnblogs.com/chengxuyuancc/p/3306963.html
votes: 0
author: 在于思考
------------------------------
title: Web API 强势入门指南
link: http://www.cnblogs.com/developersupport/p/aspnet-webapi.html
votes: 35
author: 微软互联网开发支持
------------------------------
Jumony支持的CSS3选择器列表:
选择器 | 描述 |
---|---|
* | 选择所有元素 |
p a | 选择子代元素 |
p>a | 选择子级元素 |
p a | 选择相邻元素 |
p~a | 选择后继元素 |
[attr] | 属性存在选择 |
[attr=value] | 属性值精确匹配 |
[attr~=value] | 属性值近似匹配 |
[attr^=value] | 属性值开头匹配 |
[attr*=value] | 属性值包含匹配 |
[attr$=value] | 属性值结尾匹配 |
[attr!=value] | 属性值否定匹配 |
:not | 否定伪类 |
:only-child | 唯一子元素伪类 |
:only-of-type | 唯一类型伪类 |
:empty | 空元素伪类 |
:nth-child | 结构化伪类 |
:nth-last-child | 结构化伪类 |
:nth-of-type | 结构化伪类 |
:nth-last-of-type | 结构化伪类 |
:first-child | 结构化伪类 |
:last-child | 结构化伪类 |
:first-of-type | 结构化伪类 |
:last-of-type | 结构化伪类 |