In ASP, thieves use XMLHTTP objects. Recently, I have been learning. net, the WebClient class is displayed, so I changed the program used for thieves and used ASP. net, C # to achieve, the program write is relatively simple, the purpose is to serve as a valuable author, hope to discuss with you to make it more perfect, next, I will make it possible to obtain the specified content on the webpage according to the settings. The following is the program section, including the ASP. net source program on the web page and the source program in C.
ASP. NET (getwebcontent. aspx)
<% @ Page Language = "C #" %>
<% @ Import namespace = "system. Net" %>
<% @ Import namespace = "system. Text" %>
<SCRIPT runat = Server>
//************************************** *********************
//*
// * Use ASP. NET to implement website thieves
// * Written by smile 2005-12-11
// * URL: http://blog.hnce.net
// * Email: hedongyang@gmail.com QQ: 5364083
//*
//************************************** *********************
Void page_load (Object sender, eventargs E)
{
String strurl = "http://blog.hnce.net"; // URL of the webpage to be retrieved
WebClient mywebclient = new WebClient (); // create a WebClient instance mywebclient
// Obtain or set the network creden。 used to authenticate requests to Internet resources.
Mywebclient. Credentials = credentialcache. defaultcredentials;
// Download data from the resource and return a byte array. (Add @ because there is a "/" symbol in the middle of the URL)
Byte [] pagedata = mywebclient. downloaddata (strurl );
// You only need to use one of the following two sentences at a time. The function is the same as that used to convert character sets.
// String result = encoding. Default. getstring (pagedata );
// If you use gb2312 to retrieve the website page, use this sentence.
String result = encoding. utf8.getstring (pagedata );
// Use this sentence if the UTF-8 is used to get the website page
// Because my blog uses UTF-8 encoding, so here I use this sentence
Response. Write (result); // display the obtained content on the web page
}
</SCRIPT>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>
<Body>
</Body>
</Html>
C # (getwebcontent. CS)
/*
**************************************** *****************
*
* Use C # To implement the website thief Program
* Written by smile
* URL: http://blog.hnce.net
* Email: hedongyang@gmail.com QQ: 5364083
*
**************************************** *****************
*/
Using system;
Using system. net;
Using system. text;
Class getwebcontent
{
Public static void main ()
{
Try
{
WebClient mywebclient = new WebClient ();
Mywebclient. Credentials = credentialcache. defaultcredentials;
Byte [] pagedata = mywebclient. downloaddata ("http://blog.hnce.net ");
String pagehtml = encoding. utf8.getstring (pagedata );
Console. writeline (pagehtml );
}
Catch (webexception WebEx)
{
Console. Write (WebEx. tostring ());
}
}
}
Download Code
/Files/Maxie/getwebcontent.rar