国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

XMLHttp ASP遠(yuǎn)程獲取網(wǎng)頁(yè)內(nèi)容代碼

2024-05-04 11:00:31
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:
url="http://www.csdn.net/"
wstr=getHTTPPage(url)
start=Newstring(wstr,"資源精選<!-- 下載 -->")
over=Newstring(wstr,"<div class=""friendlink"">")
body=mid(wstr,200,500)

response.write body

Function getHTTPPage(url)
dim objXML
set objXML=createobject("MSXML2.XMLHTTP")'定義
objXML.open "GET",url,false'打開
objXML.send()'發(fā)送
If objXML.readystate<>4 then '判斷文檔是否已經(jīng)解析完,以做客戶端接受返回消息
exit function
End If
getHTTPPage=bBytesToBstr(objXML.responseBody)'返回信息,同時(shí)用函數(shù)定義編碼
set objXML=nothing'關(guān)閉
if err.number<>0 then err.Clear
End Function

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
if Newstring<=0 then Newstring=Len(wstr)
End Function

Function bBytesToBstr(body)
dim objstream
set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "gb2312"
'轉(zhuǎn)換原來(lái)默認(rèn)的UTF-8編碼轉(zhuǎn)換成GB2312編碼,否則直接用XMLHTTP調(diào)用有中文字符的網(wǎng)頁(yè)得到的將是亂碼
bBytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
end Function

Function BytesToBstr(body)
dim objstream
set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "utf-8"
'轉(zhuǎn)換原來(lái)默認(rèn)的UTF-8編碼轉(zhuǎn)換成GB2312編碼,否則直接用XMLHTTP調(diào)用有中文字符的網(wǎng)頁(yè)得到的將是亂碼
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
end Function

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 陕西省| 维西| 沧源| 花莲县| 石狮市| 彰武县| 雅安市| 中西区| 来宾市| 江津市| 剑河县| 清苑县| 孟连| 简阳市| 安福县| 报价| 门源| 丰台区| 乐亭县| 广西| 贞丰县| 临泉县| 平安县| 隆昌县| 罗城| 河间市| 镇江市| 三门峡市| 南康市| 大渡口区| 台安县| 洛阳市| 宕昌县| 固镇县| 安福县| 洛浦县| 白水县| 云南省| 黄大仙区| 库伦旗| 阜阳市|