Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize ASP.NET data acquisition Program

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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+);", @"-->", @"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report