資源簡介
覺得很無聊 就 玩起了數據抓取 感覺 不錯 支持 頁面登錄 是一個完整的例子

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Net;
using?System.Collections;
using?System.IO;
namespace?UI
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????//頁面加載?就讀取指定頁面
????????????webBrowser1.Navigate(“http://www.inkfrog.com/index.php“);
????????????this.cueLbl.ForeColor?=?Color.Red;
????????????this.cueLbl.Text?=?“正在加載登錄頁面……“;
????????}
????????private?void?LoginBtn_Click(object?sender?EventArgs?e)
????????{
????????????this.cueLbl.ForeColor?=?Color.Red;
????????????this.cueLbl.Text?=?“正在登錄……請稍等“;
????????????this.UserName.Enabled?=?false;
????????????this.Password.Enabled?=?false;
????????????this.LoginBtn.Enabled?=?false;
????????????LoginText();
????????}
????????//登陸事件
????????public?void?LoginText()
????????{
????????????//找出所有input標簽
????????????HtmlElementCollection?hd?=?webBrowser1.Document.Body.GetElementsByTagName(“input“);
????????????//本事例只有3個input
????????????foreach?(HtmlElement?btn?in?hd)
????????????{
????????????????//含有action的跳過
????????????????if?(btn.Name.Equals(“action“))
????????????????????continue;
????????????????
????????????????btn.Focus();//獲得焦點
????????????????btn.InvokeMember(“click“);//單擊
????????????????//標簽里含username(看命名而改)?說明是用戶名框
????????????????if?(btn.Name.Equals(“username“))
????????????????{
????????????????????//輸入用戶名
????????????????????btn.InnerText?=?this.UserName.Text;
????????????????}
????????????????//標簽里含passwd?(看命名而改)說明是密碼框
????????????????else?if?(btn.Name.Equals(“passwd“))
????????????????{
????????????????????//輸入密碼
????????????????????btn.InnerText?=?this.Password.Text;
????????????????}
????????????}
????????}
????????//以下是處理所有訂單頁面的事件
????????private?static?ArrayList?pageNum?=?new?ArrayList();
????????public?void?Content()
????????{
????????????int?inNumber?=?0;
????????????ArrayList?options?=?new?ArrayList();
????????????
????????????this.textBox1.Text?=?““;
????????????HtmlElementCollection?hd?=?webBrowser1.Document.Body.GetElementsByTagName(“option“);
????????????foreach?(HtmlElement?btn?in?hd)
????????????{
????????????????if?(btn.OuterHtml.Contains(“of“))
????????????????{
????????????????????if?(!options.Contains(btn.OuterHtml))
????????????????????{
????????????????????????options.Add(btn.OuterHtml);
????????????????????????this.textBox1.Text?+=?btn.OuterHtml?+?“\r\n“;
????????????????????}
????????????????}
????????????}
????????????for?(int?i?=?0;?i?????????????{
????????????????string[]?str?=?options[i].ToString().Split(new?char[]?{?char.Parse(“?“)?char.Parse(“=“)?char.Parse(“<“)char.Parse(“>“)?});
????????????????pageNum.Add(Int32.Parse(str[3]));
????????????????if?(i?==?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????895??2009-03-24?17:03??數據采集\Getparms\Getparms.sln
????..A..H.?????17920??2009-04-05?13:31??數據采集\Getparms\Getparms.suo
?????文件????????249??2009-03-24?16:46??數據采集\Getparms\UI\Properties\Settings.settings
?????文件???????1176??2009-03-24?16:46??數據采集\Getparms\UI\Properties\AssemblyInfo.cs
?????文件???????3079??2009-03-24?22:33??數據采集\Getparms\UI\Properties\Resources.Designer.cs
?????文件???????1098??2009-03-24?22:32??數據采集\Getparms\UI\Properties\Settings.Designer.cs
?????文件???????6201??2009-03-24?22:33??數據采集\Getparms\UI\Properties\Resources.resx
?????文件???????8309??2009-04-05?00:44??數據采集\Getparms\UI\Form1.Designer.cs
?????文件???????5105??2009-04-05?01:56??數據采集\Getparms\UI\Form1.cs
?????文件???????3939??2009-03-25?11:43??數據采集\Getparms\UI\UI.csproj
?????文件???????5632??2005-11-11?22:25??數據采集\Getparms\UI\bin\Debug\UI.vshost.exe
?????文件??????49152??2009-04-05?01:56??數據采集\Getparms\UI\bin\Debug\UI.exe
?????文件??????34304??2009-04-05?01:56??數據采集\Getparms\UI\bin\Debug\UI.pdb
?????文件?????139264??2009-04-04?23:57??數據采集\Getparms\UI\bin\Debug\Interop.SHDocVw.dll
?????文件??????45056??2009-03-24?16:58??數據采集\Getparms\UI\bin\Debug\AxInterop.SHDocVw.dll
?????文件???????4608??2009-03-24?22:33??數據采集\Getparms\UI\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件?????139264??2009-04-04?23:57??數據采集\Getparms\UI\obj\Debug\Interop.SHDocVw.dll
?????文件????????543??2009-04-04?23:57??數據采集\Getparms\UI\obj\Debug\UI.csproj.ResolveComReference.cache
?????文件??????45056??2009-03-24?16:58??數據采集\Getparms\UI\obj\Debug\AxInterop.SHDocVw.dll
?????文件??????24260??2009-04-05?00:44??數據采集\Getparms\UI\obj\Debug\UI.Form1.resources
?????文件???????1251??2009-04-04?23:58??數據采集\Getparms\UI\obj\Debug\UI.Properties.Resources.resources
?????文件??????49152??2009-04-05?01:56??數據采集\Getparms\UI\obj\Debug\UI.exe
?????文件??????34304??2009-04-05?01:56??數據采集\Getparms\UI\obj\Debug\UI.pdb
?????文件????????883??2009-04-05?00:44??數據采集\Getparms\UI\obj\Debug\UI.csproj.GenerateResource.Cache
?????文件????????408??2009-04-05?11:41??數據采集\Getparms\UI\obj\UI.csproj.FileList.txt
?????文件??????41760??2009-04-05?00:44??數據采集\Getparms\UI\Form1.resx
?????文件????????777??2009-03-24?22:33??數據采集\Getparms\UI\Resources\loading.gif
?????文件????????461??2009-03-24?16:46??數據采集\Getparms\UI\Program.cs
?????目錄??????????0??2009-03-24?16:46??數據采集\Getparms\UI\obj\Debug\TempPE
?????目錄??????????0??2009-03-24?20:04??數據采集\Getparms\UI\obj\Debug\Refactor
............此處省略12個文件信息
評論
共有 條評論