Introduction: When doing wireless projects, some part of the communication company's data communication is interactive through XML, so we must dynamically capture data on the fixed Internet provided by the communication company, and study how to capture the fixed URL. Data, now share with you. Class name getPageCode, there is a method getSource, pass the attribute delivery parameters, the parameters are controlled to get the address of the URL, the proxy server settings and output methods, where everyone can expand their own needs, I only provide two The way, one is to write directly to a local file, and the other is to return a string. In the class, I have made more detailed notes. I think everyone is easy to understand. If I don't understand, I will ask MSN: Yubo@x263.net.
Calling method: #Region test Get remote page getPagecode GPC = new getPagecode (); gpc.url = "http://ppcode.com"; gpc.proxyState = 1; // Using proxy server, 0 is not used, set to 1 The proxy settings below act actively gpc.proxyaddress = "http://proxyname.com"; // proxy server address gpc.proxyport = "80"; // proxy server port gpc.proxyaccount = "proxy"; // Proxy server account gpc.proxypassword = "password"; // proxy server password gpc.proxyDomain = "bqc"; // proxy server domain gpc.outfilePath = filepath; // Setting the output file path, if not set, Return string gpc.getsource (); // Handling string temperr = gpc.noteMessage; // If an error, here will prompt string tempcode = gpc.outString; // Returns #ENDREGION Class code: use 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; namespace test.Com {/// /// function: get the source URL of the page on the Internet /// created: 2004-03-22 /// author: Rexsp MSN: yubo@x263.net /// summary> public class GetPageCode {#region private Variable /// /// web URL address /// summary> private string URL = null; /// // Whether to use code server: 0 Do not use 1 proxy server ////// summary> private int proxyState = 0; /// / // Proxy server address /// summary> private string proxyaddress = null; /// /// proxy server port /// summary> private string proxyport = NULL; /// / // Proxy server username /// summary> private string proxyaccount = null; /// /// proxy server password /// summary> prince swordword = null; /// /// proxy server domain /// summary> private string proxydomain = null; /// /// output file path /// summary>
Private string outfilepath = null; /// /// output string //////////////// /// 提 提 信息 信息 信息 / 信息 信息 信息 信息 信息 信息 信息 信息 信息 信息Private string NoteMessage; #endregion #region Public property /// /// want to read URL Address //// summary> public string URL {get {return;} set {url = value;}} /// // /} set {proxyState = value;}} /// /// proxy server using proxy server flag Address /// summary> public string proxyaddress {get {return proxyaddress;} set {proxyaddress = value;}} /// /// proxy server port /// summary> public string proxyport {Get {Return Proxyport;} set {proxyport = value;}} /// /// proxy server account /// summary> public string proxyaccount {get {return proxyaccount;} set {proxyaccount = value;}} /// /// proxy server password /// summary> public string proxypassword {get {return proxypassword;} set {proxypassword = value;}} /// /// proxy server domain / // summary> public string proxydomain {get {return proxydomain;} set {proxydomain = value;}} /// /// Output file path /// summary> public string outfilepath {get {return outfilepath; } Set {outfilepath = value;}} /// /// Returned String /// summary> public string outstring {get {return outstring;}} /// /// return Tips /// summary> public string noteMessage;}} #endregion #region constructor public getPagecode () {} #ENDREGION #Region public method /// /// Read specified URL address,