Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize ASP.NET data acquisition Program

Shulou Source: shulou.com Published: 2022-06-02 07:54:20 09月16日 Update

This article mainly introduces "ASP.NET data acquisition program how to achieve", in daily operation, I believe many people in ASP.NET data acquisition program how to achieve the problem there are doubts, Xiaobian consulted all kinds of information, sorting out simple and easy to use the operation method, hope to answer everyone "ASP.NET data acquisition program how to achieve" doubts help! Next, please follow the small series to learn together!

ASP.NET skills of data acquisition procedures *** step, in the beginning of downloading data, some sites are to log in to see the corresponding data, this requires us to send login user name and password, but I am logged in, but his server is not garbage, where he redirected, a total of 2 SESSION, this second SESSION I do not know how to catch. So I speculated ^-^, using software to capture SESSION down a software called Ethereal, with the following code added to the HTTP request header

WebClient myWebClient = new WebClient(); string sessionkey=textBox78.Text; string refererurl=textBox77.Text; myWebClient.Headers.Clear(); myWebClient.Headers.Add("Cookie",sessionkey); myWebClient.Headers.Add("Referer", refererurl); myWebClient.Headers.Add("User-agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3");

This will deceive the server, haha

ASP.NET skills of data acquisition procedures Step 2, code download

byte[] myDataBuffer = myWebClient.DownloadData(remoteUri); download = Encoding.Default.GetString(myDataBuffer);

ASP.NET skills of the data acquisition program third step, the data match, I will read the stream into the data, and then use IndexOf to get the location of the two key fields, and then use Substring to take out, I know this is stupid, but with regular expressions difficult ah (who will point me down), after matching the string I will use the following function to remove the HTML code:

private string StripHTML(string strHtml) { string [] aryReg ={ @"]*?>.*? ", @"", @"([\r\n])[\s]+", @"&(quot|#34);", @"&(amp|#38);", @"&(lt|#60);", @"&(gt|#62);", @"&(nbsp|#160);", @"&(iexcl|#161);", @"&(cent|#162);", @"&(pound|#163);", @"&(copy|#169);", @"&#(\d+);", @"-->", @"

Tags: Data data collection programs learning code skills logins fields that is more servers websites software problems help services utility next code download Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Apple Shulou Information NVidia