post抓取小例

2021-06-08 17:43:59 字數 1974 閱讀 2606

using system;

using system.collections.generic;

using system.text;

using system.threading;

using system.text.regularexpressions;

using iwomwebcrawlerdblayer.model;

using iwomwebcrawlerdblayer.common;

using system.net;

using system.io;

/// /// 製造post資料去模擬登入,並取回登入後的cookiecollection

///

protected override void getcookiecollection()

/// /// 根據任務生成抓取要素

///

protected override void initcrawlermodel(iwomtask taskitem)

/// /// 根據任務要素構造抓取的url

///

protected override string createurl(int pageindex)

/// /// 每抓取一頁都間隔的時間

///

protected override void pagesleep()

/// /// 頁面的編碼

///

protected override encoding getpageencoding()

/// /// 根據內容判斷是否被封禁了

///

protected override bool checkcontentisforbat(string htmlcontent)

/// /// 根據內容判斷是否是最後一頁了

///

protected override bool checkcontentislastpage(string htmlcontent)

/// /// 根據網頁資訊得到文章集合

///

protected override listgetarticlebyhtml(string htmlcontent, int task_id)

//**

item.sitename = "***";

tempmatch = regextanda.matches(matchlist[i].value.tostring());

if (tempmatch.count > 0)

tempmatch = regexrandv.matches(matchlist[i].value);

if (tempmatch.count > 0)

tempmatch = regexcontent.matches(matchlist[i].value.tostring());

if (tempmatch.count > 0)

item.filtertype = filtertype.filterno;

arraylist.add(item);}}

}}

return arraylist;

}/// /// 生成測試任務的方法

///

protected override string inittesturl()

/// /// 獲得解析的url

///

private string geturl(string urlhtml)

return "";

}#region 獲得頁面

private string getpagecontent(string url)

catch (exception)

trycatch (exception)

return htmlcontent;

}#endregion

}}

c 抓取頁面,設定POST陣列

c 抓取頁面,設定post陣列 2009 04 18 22 57 這幾天在做乙個專案 把這個拿出來分享一下 using system.io using system.text using system.data using system.windows using system.windows.fo...

爬蟲小例1 ajax形式的網頁資料的抓取

恢復內容開始 下面記錄如何抓取ajax形式載入的網頁資料 目標 獲取 下的網頁資料 第一步 網頁資料分析 特點 當列表條滾動到頁面下方時資料自動載入,而頁面的url並未發生變化 第二步 利用fiddler抓包,如下圖 圖一 請求資料 圖二 form表單 通過抓包獲取到資料規律 圖二from表單中st...

(例子)PHP 資料抓取小例子

為了加強php語言的學習,自己沒事寫了個小例子,抓取慕課網的課程列表。就是乙個簡單的小例子,沒用curl等擴充套件只用了原生的php。流程 根據url開啟 轉成字串 正規表示式提取資訊 存入資料庫。而且有乙個缺點就是因為要開啟的頁面太多,導致網路不好的情況下解析的時間太長了,會報錯停止執行。正在向方...