獲取遠(yuǎn)程網(wǎng)頁(yè)內(nèi)容實(shí)例代碼

2023-10-08    分類: 網(wǎng)站建設(shè)

Function getHTTPPage(url) 'Asp 獲取遠(yuǎn)程網(wǎng)頁(yè)內(nèi)容實(shí)例代碼
dim http
set http=Server.createobject("Microsoft.XMLHTTP")'建立XMLHTTP對(duì)象
Http.open "GET",url,false '設(shè)置http對(duì)象打開(kāi)體例 GET體例,URL[連接頁(yè)面地址],同步處理
Http.send() '發(fā)送請(qǐng)求
if Http.readystate<>4 then'對(duì)象處理狀況為 非結(jié)束
exit function '退出函數(shù)
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312")'BytesToBstr獲取的源碼轉(zhuǎn)換為中文的代碼
set http=nothing '消滅對(duì)象
if err.number<>0 then err.Clear  '消滅錯(cuò)誤
End function

'==================================================
'函數(shù)名:BytesToBstr
'作 用:將獲取的源碼轉(zhuǎn)換為中文
'參 數(shù):Body ------要轉(zhuǎn)換的變量
'參 數(shù):Cset ------要轉(zhuǎn)換的類型
'==================================================
Function BytesToBstr(body,Cset)'BytesToBstr獲取的源碼轉(zhuǎn)換為響應(yīng)的代碼
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

標(biāo)題名稱:獲取遠(yuǎn)程網(wǎng)頁(yè)內(nèi)容實(shí)例代碼
文章鏈接:http://www.bm7419.com/news44/284644.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)品牌網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)公司、Google、電子商務(wù)品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

綿陽(yáng)服務(wù)器托管