引言:
在做無線項目的時候,與通訊公司的數據通訊有一部分是通過XML交互的,所以必須要動態抓取通訊公司提供的固定的Internet上的數據,便研究了一下如何抓取固定url上的數據,現與大家分享一下。
調用方式:
#region 測試獲取遠程網頁
GetPageCode gpc = new GetPageCode();
gpc.Url="http://ppcode.com";
gpc.PRoxyState=1;//使用代理服務器,0為不使用,設置為1后下面的代理設置才起作用
gpc.ProxyAddress="http://proxyName.com";//代理服務器地址
gpc.ProxyPort="80";//代理服務器的端口
gpc.ProxyAccount="proxy";//代理服務器賬號
gpc.ProxyPassWord="password";//代理服務器密碼
gpc.ProxyDomain="bqc";//代理服務器域
gpc.OutFilePath=filePath;//設置輸出文件路徑的地方,假如不設置,則返回字符串
gpc.GetSource();//處理
string tempErr=gpc.NoteMessage;//假如出錯,這里會提示
string tempCode=gpc.OutString;//返回的字符串
#endregion
類代碼:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
進入討論組討論。
新聞熱點
疑難解答