統計個人部落格園文章資料(WPF4 版)

2021-09-05 23:29:49 字數 2623 閱讀 2678

每當需要整理部落格文章資料時總感覺很繁瑣。雖然有許多功能強大的統計工具(例如,谷歌分析),但是僅限於載入該工具時至今的資料。對於早期未加入統計範圍的博文來說就顯得很不準確了。管理頁面中雖然也有博文詳細資訊,但要提取出來也很麻煩,總不能每頁複製->貼上到excel 吧。

的隨筆檔案是按每月博文進行歸總的頁面,例如「 會列出我在2023年4月寫過的所有文章。瀏覽該頁面的html **會看到類似下面的**片段(**格式在本文中調整過)。

<

div

class

="entrylistposttitle">

<

a id

="archivemonth1_days_entries_ctl00_titleurl"

class

="entrylistitemtitle"

href

="">

microsoft rex 正規表示式工具

a>

div>

<

div

class

="entrylistpostsummary">

摘要: <

img

src=""

class

="desc_img"/>

這裡都是摘要內容… …

<

a href

=''>閱讀全文

a>

div>

<

div

class

="entrylistitempostdesc">

posted @ <

a href

= title

= "permalink">2010-04-17 09:42

a>

gnie 閱讀(1574) | <

a href

=#feedback

title

a>

<

a href

="">編輯

a>

div>

首先通過webclient按月獲取到隨筆檔案的html **,並針對標題中的一些特殊字串(例如,&)進行替換:

private string gethtmlcode(string struid, string strmonth)

/archive/.html", struid, strmonth);

string htmlcode = client.downloadstring(url);

htmlcode = htmlcode.replace("&", "&");

htmlcode = htmlcode.replace("

htmlcode = htmlcode.replace(">", ">");

return htmlcode;

}

public class 

article

public url

public int read

public int comment

}

observablecollection

bloginfo = new

observablecollection

();private void getblogdata(string strdate, string strpattern)

); }

}

最後,通過乙個button 事件觸發以上方法,其中比較費事的就是正規表示式的定義regexpattern,將所有取到的資料與datagrid 列表進行binding。

private void gobtn_click(object sender, routedeventargs e)

else

int readcount = 0, commentcount = 0;

foreach (article bloglist in bloginfo)

sumlabel.content = string.format("article: read: comment: ",

bloginfo.count.tostring(),readcount.tostring(),commentcount.tostring());

datagrid.datacontext = bloginfo;}}

資料的抓取速度取決於隨筆檔案的數量和當時的網速。有時我這裡上很慢,那就別指望取到資料了。以下是軟體截圖,其中還新增了將資料匯出excel 的功能。

2. wpf 4 datagrid 控制項(基本功能篇)

3. wpf 4 datagrid 控制項(自定義樣式篇)

4. wpf 4 datagrid 控制項(高階篇一)

統計個人部落格園文章資料(WPF4 版)

每當需要整理部落格文章資料時總感覺很繁瑣。雖然有許多功能強大的統計工具 例如,谷歌分析 但是僅限於載入該工具時至今的資料。對於早期未加入統計範圍的博文來說就顯得很不準確了。管理頁面中雖然也有博文詳細資訊,但要提取出來也很麻煩,總不能每頁複製 貼上到excel 吧。的隨筆檔案是按每月博文進行歸總的頁面...

統計部落格園個人部落格的訪問量

本文參照了博文 在後台管理的設定選項中有乙個公告欄和設定頁首頁尾 功能,使用起來非常靈活和方便。藉此我們可以通過網路上提過的其他強大的外掛程式來為獲取更加詳細的訪問統計資訊。本教程所使用的方法對於其他提供類似公告欄機制的任何網路頁面都適用,而不僅僅限於。首先我們先進入這個外國的 有可能打不開需要fq...

製作自己部落格園文章簽名

看到園子裡很多的前輩在發表自己的文章和想法的時候,文章後面都有乙個版權資訊的宣告,感覺上很是講究,很想也做乙個和前輩們一樣的東西,今天也仿著他們的簽名做了乙個,沒有什麼突出的地方,效果圖如下 這樣部落格看起來很是新穎,有兩種做法 第一種步驟如下 1.在後台管理介面寫隨筆的地方,點選左側的維護簽名,起...