<button id="nc8ni"><xmp id="nc8ni"><button id="nc8ni"></button><ins id="nc8ni"><button id="nc8ni"><form id="nc8ni"></form></button></ins>
<button id="nc8ni"><form id="nc8ni"></form></button>
<form id="nc8ni"><xmp id="nc8ni">
<ins id="nc8ni"><button id="nc8ni"></button></ins>
<button id="nc8ni"><xmp id="nc8ni">
<ins id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></ins>
<button id="nc8ni"><xmp id="nc8ni">
<button id="nc8ni"><xmp id="nc8ni">
<button id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></button><button id="nc8ni"><form id="nc8ni"></form></button>
<button id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></button><button id="nc8ni"><xmp id="nc8ni"><button id="nc8ni"></button><form id="nc8ni"><ins id="nc8ni"><form id="nc8ni"></form></ins></form><button id="nc8ni"><xmp id="nc8ni"><ins id="nc8ni"></ins>
<button id="nc8ni"><xmp id="nc8ni"><ins id="nc8ni"></ins><form id="nc8ni"><ins id="nc8ni"><form id="nc8ni"></form></ins></form>
<ins id="nc8ni"><form id="nc8ni"></form></ins>
<button id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></button>
<button id="nc8ni"></button>
<button id="nc8ni"></button>
訂閱本欄目 RSS您所在的位置: 深山工作室 > ASP > 正文

利用Asp里的xmlhttp組件來(lái)獲取頁(yè)面內容

網(wǎng)絡(luò ) 2009/1/23 9:49:55 深山行者 字體: 瀏覽 14147
以下是引用片段:

以下文件保存為:test.asp  后運行

<%
on error resume next
time1=timer
dim reg,vUrl,VBody,temp1,temp2,code,time1,time2,title
vUrl=trim(request.form("url"))
reg="\<meta.+ charset= {0,}([^\""| |\>|\/]*).+\/{0,1}\>"
if vUrl<>"" then
  VBody=GetResStr(trim(request.form("url")))
  temp1=VBody:temp2=VBody
  code=GetCode(temp1,reg)
  title=GetCode(temp2,"\<title\>(.*)\<\/title\>")
else
  vUrl="http://"
end if
time2=timer
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>抓取頁(yè)面</title>
<%if err.number<>0 then%>
<script language="javascript">alert('發(fā)生錯誤!\n您輸入的URL為\"<%=vUrl%>\"\n請檢查您輸入的URL是否合法!');</script>
<%end if%>
</head>
<body style="font-size:12px;margin:20px 0 0 20px;">
<form name="geturl" action="test.asp" method="post">
請輸入合法URL(必須以http://開(kāi)頭):<br /><input name="url" type="text" size=60 value="<%=vUrl%>"/><br />
<input type="submit" value="抓取" /><br />
</form>
所用時(shí)間:<font color=green><%=formatnumber((time2-time1)*1000,2)%>MS</font> <br />
頁(yè)面標題:<font color=green><%=title%></font> 頁(yè)面編碼:<font color=green><%=code%></font> <br />
<textarea cols=150 rows=30><%=VBody%></textarea>
</body>
</html>

<% 
function GetResStr(URL)
dim ResBody,ResStr,PageCode
Set Http=server.createobject("msxml2.serverxmlhttp.3.0") 
Http.setTimeouts 10000, 10000, 10000, 10000 
Http.open "GET",URL,False 
Http.Send() 
If Http.Readystate =4 Then 
  If Http.status=200 Then
    ResStr=http.responseText
    ResBody=http.responseBody
    PageCode=GetCode(ResStr,reg)
    GetResStr=BytesToBstr(http.responseBody,PageCode)
  End If 
End If 
End Function

'函數名:BytesToBstr
'作用:轉換二進(jìn)制數據為字符
'參數:Body-二進(jìn)制數據,Cset-文本編碼方式
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
 
'函數名:GetCode
'作用:轉換二進(jìn)制為字符
'參數:str-待查詢(xún)字符串,regstr-正則表達式
Function GetCode(str,regstr)
Dim Reg
set Reg= new RegExp
Reg.IgnoreCase = True
Reg.MultiLine = True
Reg.Pattern =regstr
Set Cols = Reg.Execute(str)
str=Cols(0).SubMatches(0)
GetCode=str
end function
%>


相關(guān)閱讀
javascript_vb_asp代碼轉換器
內蒙古香格里拉旅行社有限公司
可以用于考試系統中試卷上交的javascript倒計時(shí)
ASP操作access或sqlserver數據庫的函數庫
javascript自動(dòng)獲取Tags關(guān)鍵字
下載微信小程序
JS代碼判斷集錦(之二)
仿淘寶首頁(yè)商品分類(lèi)列表效果
共有0條關(guān)于《利用Asp里的xmlhttp組件來(lái)獲取頁(yè)面內容》的評論
發(fā)表評論
正在加載評論......
返回頂部發(fā)表評論
呢 稱(chēng):
表 情:
內 容:
評論內容:不能超過(guò) 1000 字,需審核,請自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)政策法規。
驗證碼: 驗證碼 
網(wǎng)友評論聲明,請自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)政策法規。

您發(fā)布的評論即表示同意遵守以下條款:
一、不得利用本站危害國家安全、泄露國家秘密,不得侵犯國家、社會(huì )、集體和公民的合法權益;
二、不得發(fā)布國家法律、法規明令禁止的內容;互相尊重,對自己在本站的言論和行為負責;
三、本站對您所發(fā)布內容擁有處置權。

更多信息>>欄目類(lèi)別選擇
百度小程序開(kāi)發(fā)
微信小程序開(kāi)發(fā)
微信公眾號開(kāi)發(fā)
uni-app
asp函數庫
ASP
DIV+CSS
HTML
python
更多>>同類(lèi)信息
ASP中Utf-8與Gb2312編碼轉換亂碼問(wèn)題的解決方法頁(yè)面編碼聲明
asp顯示隨機密碼
通過(guò)阿里云服務(wù)接口獲得ip地址詳細信息
iis點(diǎn)開(kāi)后任務(wù)欄上有顯示,但是窗口看不到的解決辦法
RSA加密解密插件
微軟Encoder加密解密函數
更多>>最新添加文章
dw里面查找替換使用正則刪除sqlserver里面的CONSTRAINT
Android移動(dòng)端自動(dòng)化測試:使用UIAutomatorViewer與Selenium定位元素
抖音直播音掛載小雪花 懂車(chē)帝小程序
javascript獲取瀏覽器指紋可以用來(lái)做投票
火狐Mozilla Firefox出現:無(wú)法載入您的Firefox配置文件 它可能已經(jīng)丟失 或是無(wú)法訪(fǎng)問(wèn) 問(wèn)題解決集合處理辦法
在A(yíng)ndroid、iOS、Windows、MacOS中微信小程序的文件存放路徑
python通過(guò)代碼修改pip下載源讓下載庫飛起
python里面requests.post返回的res.text還有其它的嗎
更多>>隨機抽取信息
有利于搜索引擎的一些常用的CSS命名規則
ASP.Net 2.0中的5個(gè)數據控件
css分頁(yè)放大效果
JS壓縮
javascript自動(dòng)獲取Tags關(guān)鍵字
python自動(dòng)控制鼠標操作pymouse
亚洲精品456在线|S级爆乳玩具酱国产VIP皮裤|欧美成人精品第一区二区三区|久久永久免费人妻精品我不卡|亚洲欧洲日产无码
<button id="nc8ni"><xmp id="nc8ni"><button id="nc8ni"></button><ins id="nc8ni"><button id="nc8ni"><form id="nc8ni"></form></button></ins>
<button id="nc8ni"><form id="nc8ni"></form></button>
<form id="nc8ni"><xmp id="nc8ni">
<ins id="nc8ni"><button id="nc8ni"></button></ins>
<button id="nc8ni"><xmp id="nc8ni">
<ins id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></ins>
<button id="nc8ni"><xmp id="nc8ni">
<button id="nc8ni"><xmp id="nc8ni">
<button id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></button><button id="nc8ni"><form id="nc8ni"></form></button>
<button id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></button><button id="nc8ni"><xmp id="nc8ni"><button id="nc8ni"></button><form id="nc8ni"><ins id="nc8ni"><form id="nc8ni"></form></ins></form><button id="nc8ni"><xmp id="nc8ni"><ins id="nc8ni"></ins>
<button id="nc8ni"><xmp id="nc8ni"><ins id="nc8ni"></ins><form id="nc8ni"><ins id="nc8ni"><form id="nc8ni"></form></ins></form>
<ins id="nc8ni"><form id="nc8ni"></form></ins>
<button id="nc8ni"><form id="nc8ni"><ins id="nc8ni"></ins></form></button>
<button id="nc8ni"></button>
<button id="nc8ni"></button>