php远程抓取网页和asp远程抓取网页

php:

<?php
$url="http://www.baidu.com/index.html";
echo file_get_contents( $url );
?>

 

asp:

 

<%
Function GetBodyX(weburl)
dim Retrieval
'Set Retrieval = CreateObject("Microsoft." & "XMLHTTP")
Set Retrieval = CreateObject("MSXML2." & "XMLHTTP")
Retrieval.Open "Get",weburl,False,"",""
Retrieval.Send
GetBodyX = Retrieval.ResponseBody
Set Retrieval = Nothing
End Function

Function BytesToBstr(body,Cset)
'编码常用为GB2312和UTF-8
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

dim getHTML
getHTML = GetBodyX("http://www.baidu.com/index.html")
getHTML = BytesToBstr(getHTML,"GB2312")
response.write(getHTML)
%>

 

 

 

已经打包,需要自行下载研究

附件下载:

远程抓取网页php和asp.rar767字节