Scaff the source code of the specified URL from the Internet (C #)

xiaoxiao2021-03-06  112

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 /// public class GetPageCode {#region private Variable /// /// web URL address /// private string URL = null; /// // Whether to use code server: 0 Do not use 1 proxy server ////// private int proxyState = 0; /// / // Proxy server address /// private string proxyaddress = null; /// /// proxy server port /// private string proxyport = NULL; /// / // Proxy server username /// private string proxyaccount = null; /// /// proxy server password /// prince swordword = null; /// /// proxy server domain /// private string proxydomain = null; /// /// output file path ///

Private string outfilepath = null; ///

/// output string //////////////// /// 提 提 信息 信息 信息 / 信息 信息 信息 信息 信息 信息 信息 信息 信息 信息Private string NoteMessage; #endregion #region Public property /// /// want to read URL Address //// public string URL {get {return;} set {url = value;}} /// // /} set {proxyState = value;}} /// /// proxy server using proxy server flag Address /// public string proxyaddress {get {return proxyaddress;} set {proxyaddress = value;}} /// /// proxy server port /// public string proxyport {Get {Return Proxyport;} set {proxyport = value;}} /// /// proxy server account /// public string proxyaccount {get {return proxyaccount;} set {proxyaccount = value;}} /// /// proxy server password /// public string proxypassword {get {return proxypassword;} set {proxypassword = value;}} /// /// proxy server domain / // public string proxydomain {get {return proxydomain;} set {proxydomain = value;}} /// /// Output file path /// public string outfilepath {get {return outfilepath; } Set {outfilepath = value;}} /// /// Returned String /// public string outstring {get {return outstring;}} /// /// return Tips /// public string noteMessage;}} #endregion #region constructor public getPagecode () {} #ENDREGION #Region public method /// /// Read specified URL address,

转载请注明原文地址:https://www.9cbs.com/read-102769.html

New Post(0)