校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > 用正則和xmlHttp實現(xiàn)的asp小偷程序

用正則和xmlHttp實現(xiàn)的asp小偷程序

熱門標(biāo)簽:為什么外呼系統(tǒng)需要預(yù)存話費(fèi)呢 寧夏怎么申請400電話 蘭州智能語音電銷機(jī)器人功能 離線電子地圖標(biāo)注軟件注冊 外呼回?fù)芟到y(tǒng)圖片 常用地圖標(biāo)注范圍點(diǎn) 企數(shù)外呼系統(tǒng)能用多久 辦理400電話一年多少錢 咸陽銷售外呼系統(tǒng)
復(fù)制代碼 代碼如下:


'======================================== 
class EngineerSearch 
'老龍:laolong9999@sina.com 
':模擬XML獲取http標(biāo)記資源(用過之后就知道為什么XML有用:)) 
'利用引擎搜索(顯示引擎信息或其超連接網(wǎng)站上的信息或直接一個指定頁面的相關(guān)信息,利用正則和xmlHttp, 
'程序的使用需要會構(gòu)造正則) 
'--------------------------------------------------------------- 
private oReg,oxmlHttp'一個正則,一個微軟xmlhttp 
'--------------------------------------------------------------- 
public sub class_initialize()'對象建立觸發(fā) 
set oReg=new regExp 
oReg.Global=true 
oReg.IgnoreCase=true 
set oXmlHttp=server.createobject("Microsoft.XmlHttp") 
end sub 
'--------------------------------------------------------------- 
public sub class_terminate()'對象銷毀觸發(fā) 
set oReg=nothing'必須手動釋放class內(nèi)的自建對象,asp只自動釋放由class定義的對象 
set oXmlHttp=nothing 
If typename(tempReg)>"nothing" then'方法體內(nèi)的對象釋放資源 
set tempReg=nothing 
end if 
end sub 
'--------------------------------------------------------------- 
'引擎級搜索 
public function engineer(url,EngineerReg) 
'功能介紹:獲得url的返回信息(通常用于引擎查找),提取其中的EngineerReg的特定信息,返回matches集合到 
'函數(shù)名。獲得url查詢結(jié)果,搜尋出用engineerReg正則定義的結(jié)果,生成一個matches集合, 
'由于無法建立集合及操作集合個數(shù)(vbscript),最好再自己遍歷集合,也可以考慮二維數(shù)組 
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 
'--------------------------------------------------------------- 
'漢字編碼,(網(wǎng)人) 
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="(^.*\/).*$"'含文件名的標(biāo)準(zhǔn)路徑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一定是包含文件擴(kuò)展名的完整地址,結(jié)果是集合,集合中的每個項目是數(shù)組,應(yīng)該這樣引用子查詢: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 
%> 

更諸多的應(yīng)用,只要你會正則

標(biāo)簽:昌都 咸陽 家電維修 溫州 鐵嶺 麗江 泰州 昆明

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用正則和xmlHttp實現(xiàn)的asp小偷程序》,本文關(guān)鍵詞  用,正則,和,xmlHttp,實現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《用正則和xmlHttp實現(xiàn)的asp小偷程序》相關(guān)的同類信息!
  • 本頁收集關(guān)于用正則和xmlHttp實現(xiàn)的asp小偷程序的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 高平市| 新宁县| 精河县| 高雄市| 昌平区| 房产| 广东省| 邵阳县| 思茅市| 澜沧| 南汇区| 尚义县| 丹棱县| 广德县| 静海县| 徐水县| 长沙市| 黎城县| 讷河市| 聊城市| 正安县| 抚远县| 高安市| 溧水县| 静宁县| 石景山区| 拜城县| 三原县| 泰兴市| 普宁市| 会同县| 肇源县| 年辖:市辖区| 垫江县| 房山区| 龙井市| 钦州市| 安福县| 九寨沟县| 浑源县| 吉木乃县|