Dim wstr,str,url,start,over,dtime
Url= "http://mb.111cn.net/"
Wstr=gethttppage (URL)
Body=wstr
<%
' Use ASP to get Remote target Web page specified content
On Error Resume Next
server.scripttimeout=9999999
function Gethttppage (path)
t = getbody (PATH)
Gethttppage=bytestobstr (T, "gb2312")
End Function
function NewString (WSTR,STRNG)
Newstring=instr (LCase (WSTR), LCase (STRNG))
If Newstring<=0 then Newstring=len (WSTR)
End Function
function Bytestobstr (body,cset)
Dim objstream
Set objstream = Server.CreateObject ("ADODB.stream")
objStream.Type = 1
Objstream.mode =3
objStream.Open
Objstream.write body
objstream.position = 0
objStream.Type = 2
Objstream.charset = Cset
Bytestobstr = Objstream.readtext
objStream.Close
Set objstream = Nothing
End Function
function GetBody (URL)
On Error Resume Next
Set retrieval = CreateObject ("Microsoft.XMLHTTP")
With retrieval
. Open "Get", url, False, "", ""
. Send
GetBody =. Responsebody
End With
Set retrieval = Nothing
End Function
' ASP gets remote Web page specified content start
Dim wstr,str,url,start,over,dtime
A= "Start content" ASP get the target page content start tag
b= "End Content" ASP get Web page content end tag
Url= "http://mb.111cn.net/"
Wstr=gethttppage (URL)
Start=newstring (Wstr,a)
Over=newstring (WSTR,B)
Body=mid (Wstr,start,over-start)
Response.Write "" &body& "' output to the content of the Web page acquired
' ASP get remote Web page specified end of content
%>
A asp.net tutorial to capture remote server data
' Using System;
Using System.Collections.Generic;
Using System.Text;
Using System.Net;
Using System.IO;
Namespace thief
{
Class Program
{
static void Main (string[] args)
{
try {
WebClient mywebclient = new WebClient ();
Mywebclient.credentials = credentialcache.defaultcredentials;//Gets or sets the network credentials used to authenticate requests to Internet resources.
byte[] Pagedata = Mywebclient.downloaddata ("http://www.111cn.net")//download data from the specified Web site
String pagehtml = Encoding.default.getstring (pagedata); If you get the site page using gb2312, use this sentence
String pagehtml = Encoding.utf8.getstring (pagedata); If you get the site page using Utf-8, use this sentence
Console.WriteLine (pagehtml);//What you get in the console input
using (StreamWriter sw = new StreamWriter ("c:estouput.html"))//writes the acquired content to the text
{
Sw.write (pagehtml);
}
Console.ReadLine (); Let the console pause, or it will flash past.
}
catch (WebException WebEx) {
Console.WriteLine ( Webex.message.tostring ());
}
}
}
}