【人在江湖飄,哪有不帶刀】神器Jumony


大神博客: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 結構化偽類

 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com