最新消息:重新回归WordPress,我要比较认真的开始更新我的博客了。

asp远程读取网页源代码

程序问题 hanlei 1078浏览

‘读取数据
Function GetURL(URL)
Set http=Server.CreateObject(“Microsoft.XMLHTTP”)
On Error Resume Next
http.Open “GET”,URL,False
http.send()
if Err then
Err.Clear
Response.Write(“没有找到网页!”)
Response.End()
End if
getHTTPPage=bytesToBSTR(Http.responseBody,”gb2312″)
set http=nothing
GetURL=getHTTPPage
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
‘调用方法
Content=GetURL(http://www.lan27.com)
Response.Write(Content)

转载请注明:HANLEI'BLOG » asp远程读取网页源代码