用正则和xmlHttp实现的asp小偷程序_小偷/采集

复制代码 代码如下:

<% 
'======================================== 
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 
%> 

更诸多的应用,只要你会正则

时间: 2024-09-20 16:57:56

用正则和xmlHttp实现的asp小偷程序_小偷/采集的相关文章

如何写ASP入库小偷程序_小偷/采集

现在网上流行的小偷程序比较多,有新闻类小偷,音乐小偷,下载小偷,那么它们是如何做的呢,下面我来做个简单介绍,希望对各位站长有所帮助. (一)原理 小偷程序实际上是通过了XML中的XMLHTTP组件调用其它网站上的网页.比如新闻小偷程序,很多都是调用了sina的新闻网页,并且对其中的html进行了一些替换,同时对广告也进行了过滤.用小偷程序的优点有:无须维护网站,因为小偷程序中的数据来自其他网站,它将随着该网站的更新而更新:可以节省服务器资源,一般小偷程序就几个文件,所有网页内容都是来自其他网站.

asp alexa查询小偷程序_小偷/采集

<% '为了支持原创,请保留该处注释,谢谢! '作者:草上飞 '获取主域名 Function getDomainUrl(url)     tempurl=replace(url,"http://","")     if instr(tempurl,"/")>0 then         tempurl=left(tempurl,instr(tempurl,"/")-1)     end If     getDoma

用asp获取微软安全更新列表的代码 小偷程序_小偷/采集

复制代码 代码如下: <% Function Bytes2bStr(vin,cSet) Dim BytesStream,StringReturn Set BytesStream = Server.CreateObject("ADODB.Stream") BytesStream.Type = 2 BytesStream.Open BytesStream.WriteText vin BytesStream.Position = 0 BytesStream.CharSet = cSet

Bat自动解压缩发布asp.net程序_实用技巧

1解压缩压缩包 2替换文件 3停止服务 4重建虚拟目录 5重启服务 @echo 1.Zipexe 好压压缩程序集路径 @echo 2.zipFileName 压缩文件的路径 @echo 3.ylxt 解压缩文件的路径 @echo 3.webconstant 发布目录中不会修改的文件.和文件夹,需要和虚拟目录的目录结构保持一致 @echo 4.PubparentFolder 虚拟目录的父目录 @echo 5.PubFolderName 虚拟目录名 set Zipexe="C:\Program Fi

用xmlhttp编写web采集程序_小偷/采集

晰带语法着色的版本:http://gwx.showus.net/blog/article.asp?id=229 原创很辛苦,转载请注明原文链接:http://gwx.showus.net/blog/article.asp?id=229 web采集程序?网页抓取程序?小倫程序?不管怎么叫,这种程序应用倒是蛮广的.本文不讨论这种使用这种程序引起的版权或道德问题,只谈这种程序在ASP+VBScript环境下的实现 :-) 预备知识:除了一般的ASP+VBScript的知识外,你还需要了解xmlhttp

用XMLHTTP来偷东西哈!_小偷/采集

只做了一部份,IP查询请大家自己照着我里边的样例自己完成吧!演示:http://www.goalercn.com/demo/searcher.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "' target=_blank rel=nofollow>h

实例讲解实现抓取网上房产信息的ASP程序_小偷/采集

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!-- #include file="conn.asp" --> <!-- #include file="inc/function.asp" --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "h

用XMLHTTP很好的一个例子_小偷/采集

进入www.ting88.com的网站,把歌手专辑页面的URL复制到文本框中再提交就可以得到歌曲的下载路径,如:http://www.ting88.com/MusicList/4141.htm  源程序如下:  <%  on error resume next  dim id,url,getCode,m,i,j,s,d,ns,nd,num,name  id=trim(request.querystring("id"))  '1.获取原网页所有内容  Function getHTT

XMLHTTP批量抓取远程资料_小偷/采集

可以在此基础上结合正则表达式做成更好的效果,希望大家能分享一下Xmlhttp的session共享技术  <html>  <head>  <title>AUTOGET</title>  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  </head>  <body bgcolor="#FFFF