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

首頁 > 編程 > ASP > 正文

用正則和xmlHttp實現的asp小偷程序

2024-05-04 10:58:19
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

<% 
'======================================== 
class EngineerSearch 
'老龍:laolong9999@sina.com 
':模擬XML獲取http標記資源(用過之后就知道為什么XML有用:)) 
'利用引擎搜索(顯示引擎信息或其超連接網站上的信息或直接一個指定頁面的相關信息,利用正則和xmlHttp, 
'程序的使用需要會構造正則) 
'--------------------------------------------------------------- 
private oReg,oxmlHttp'一個正則,一個微軟xmlhttp 
'--------------------------------------------------------------- 
public sub class_initialize()'對象建立觸發 
set oReg=new regExp 
oReg.Global=true 
oReg.IgnoreCase=true 
set oXmlHttp=server.createobject("Microsoft.XmlHttp") 
end sub 
'--------------------------------------------------------------- 
public sub class_terminate()'對象銷毀觸發 
set oReg=nothing'必須手動釋放class內的自建對象,asp只自動釋放由class定義的對象 
set oXmlHttp=nothing 
If typename(tempReg)<>"nothing" then'方法體內的對象釋放資源 
set tempReg=nothing 
end if 
end sub 
'--------------------------------------------------------------- 
'引擎級搜索 
public function engineer(url,EngineerReg) 
'功能介紹:獲得url的返回信息(通常用于引擎查找),提取其中的EngineerReg的特定信息,返回matches集合到 
'函數名。獲得url查詢結果,搜尋出用engineerReg正則定義的結果,生成一個matches集合, 
'由于無法建立集合及操作集合個數(vbscript),最好再自己遍歷集合,也可以考慮二維數組 
dim strConent 
strContent=oXmlHttp.open("get",url,false) 
on error resume next 
oXmlHttp.send() 
if err.number<>0 then 
exit function 
end if 
strContent=bytes2BSTR(oXmlHttp.responseBody) 
if isnull(EngineerReg) then 
engineer=AbsoluteURL(strContent,url) 
else 
oReg.Pattern=EngineerReg 
set engineer=oReg.Execute(AbsoluteURL(strContent,url))  
end if 
end function 
'--------------------------------------------------------------- 
'漢字編碼,(網人) 
public Function bytes2BSTR(vIn)  
strReturn = ""  
For i = 1 To LenB(vIn)  
ThisCharCode = AscB(MidB(vIn,i,1))  
If ThisCharCode < &H80 Then  
strReturn = strReturn & Chr(ThisCharCode)  
Else  
NextCharCode = AscB(MidB(vIn,i+1,1))  
strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode))  
i = i + 1  
End If  
Next  
bytes2BSTR = strReturn  
End Function 
'--------------------------------------------------------------- 
public Function SearchReplace(strContent,ReplaceReg,ResultReg) 
'替換,將strContent中的replaceReg描述的字符串用resultReg描述的替換,返回到searchReplace去 
'將正則的replace封裝了。 
oReg.Pattern=ReplaceReg 
SearchReplace=oReg.replace(strContent,ResultReg) 
End Function 
'--------------------------------------------------------------- 
public Function AbsoluteURL(strContent,byval url) 
'將strContent中的相對URL變成oXmlHttp中指定的url的絕對地址(http/https/ftp/mailto:) 
'正則可以修改修改。 
dim tempReg 
set tempReg=new RegExp 
tempReg.IgnoreCase=true 
tempReg.Global=true 
tempReg.Pattern="(^.*//).*$"'含文件名的標準路徑http://www.wrclub.net/default.aspx 
Url=tempReg.replace(url,"$1") 
tempReg.Pattern="((?:src|href).*?=[/'/u0022](?!ftp|http|https|mailto))" 
AbsoluteURL=tempReg.replace(strContent,"$1"+Url) 
set tempReg=nothing 
end Function 
'--------------------------------------------------------------- 
end class 
'======================================== 
%> 
<%'例子 
Response.CharSet = "GB2312"  
dim mySearch  
set mySearch=new EngineerSearch 
'URL一定是包含文件擴展名的完整地址,結果是集合,集合中的每個項目是數組,應該這樣引用子查詢:myMatches(0).subMatches(0) 
set myMatches=mySearch.engineer("http://www.wrclub.net/default.aspx","<img.*?>") 
if myMatches.count=0 Then 
response.write "沒有你正則的字符串" 
end if 
if myMatches.count>0 then 
response.write myMatches.count&"<br>" 
for each key in myMatches 
response.write key.firstindex&":"&cstr(key.value)&"<br>" 
next 
end if 
%> 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 舟山市| 驻马店市| 驻马店市| 柳州市| 呼和浩特市| 城市| 泗洪县| 博野县| 永丰县| 论坛| 晋城| 大兴区| 手游| 宾阳县| 金坛市| 大洼县| 房产| 莒南县| 安溪县| 阿合奇县| 安溪县| 蓝山县| 甘南县| 丰顺县| 淳安县| 卢湾区| 阳信县| 定安县| 陇西县| 峨山| 江达县| 新巴尔虎左旗| 武城县| 潼关县| 松潘县| 含山县| 惠州市| 张家界市| 济源市| 衡南县| 信宜市|