Ver2005  最终版

 代码如下:

<% 
'转发时请保留此声明信息,这段声明不并会影响你的速度!
'**************************   【先锋海盗类】ver2005  最终版********************************
'作者:孙立宇、apollosun、ezhonghua
'改进者:arllic 
'【消除所有的bug,去掉了一些不易使用,容易使人误解的功能,优化了执行效率,此为最终版】
'官方网站:http://www.lkstar.com   技术支持论坛:http://bbs.lkstar.com
'电子邮件:kickball@netease.com    在线qq:94294089
'版权声明:版权没有,盗版不究,源码公开,各种用途均可免费使用,欢迎你到技术论坛来寻求支持。
'——小偷程序的原理是通过xhtml和asp技术相结合,定向集中采集远程网页内容加工后转为本地虚拟网页。
'——此技术自诞生以来由于它的信息覆盖面、广同步更新和免维护的特性一直受到各编程爱好者的关注和追捧。
'——目前国内比较流行的实时新闻、闪客动漫、流行歌曲、软件下载、天气预报、股票查询等优秀作品。
'——然而由于制作小偷程序的过程过于复杂和繁琐,还由于远程网页代码的变更而经常失效,这使小偷网页的
'维护成为一个噩梦!所以到目前为止,目前此类佳作不多,技术也集中在小部分人手中。
'——先锋海盗类的诞生将使小偷程序的制作和维护变得容易起来。先锋海盗类提供的12种类方法将使你对采集
'内容的编辑掌控能力变得空前强大,另有贴心的类排错debug方法可以使你随时观察自己在各步骤获得的代码和
'页面显示效果,彻底掌握这些类方法将使你为所欲为地采集编辑各种远程页面,而且维护也相当方便!
'——总而言之,使用先锋海盗类将使你的"小偷"程序晋升为"海盗"程序!
'详细使用说明或范例请见下载附件或到本人官方站点下载!
'-------------------------------------------------------------------------------------
class clsthief
'____________________
private value_    '窃取到的内容
private src_      '要偷的目标url地址
private isget_    '判断是否已经偷过

public property let src(str) '赋值—要偷的目标url地址/属性
src_=str
end property

public property get value '返回值—最终窃取并应用类方法加工过的内容/属性
value=value_
end property

public property get version
    version="先锋海盗类 version 2005"
end property

private sub class_initialize()
value_=""
src_=""
isget_= false
end sub

private sub class_terminate()
end sub

private 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

public sub steal() '窃取目标url地址的html代码/方法
if src_<>"" then
    dim http
    set http=server.createobject("msxml2.xmlhttp")
    http.open "get",src_ ,false
    http.send()
    if http.readystate<>4 then 
        exit sub
    end if
    value_=bytestobstr(http.responsebody,"gb2312")
    isget_= true
    set http=nothing
    if err.number<>0 then err.clear
else 
    response.write(" ")
end if
end sub

'删除偷到的内容中里面的换行、回车符以便进一步加工/方法
public sub noreturn() 
if isget_= false then call steal()
value_=replace(replace(value_ , vbcr,""),vblf,"")
end sub

'对偷到的内容中的个别字符串用新值更换/方法
public sub change(oldstr,str) '参数分别是旧字符串,新字符串
if isget_= false then call steal()
value_=replace(value_ , oldstr,str)
end sub

'按指定首尾字符串对偷取的内容进行裁减(不包括首尾字符串)/方法
public sub cut(head,bot) '参数分别是首字符串,尾字符串
if isget_= false then call steal()
        if instr(value_ , head)>0 and instr(value_ , bot)>0 then
            value_=mid(value_ ,instr(value_ ,head)+len(head),instr(value_ ,bot)-instr(value_ ,head)-len(head))
        else
            value_= "函数cut指定裁减内容不存在,请重新定义"
        end if
end sub

'按指定首尾字符串对偷取的内容进行裁减(包括首尾字符串)/方法
public sub cutx(head,bot) '参数分别是首字符串,尾字符串
if isget_= false then call steal()
        if instr(value_,head)>0 and instr(value_,bot)>0 then
            value_=mid(value_ ,instr(value_ ,head),instr(value_ ,bot)-instr(value_ ,head)+len(bot))
        else
            value_= "函数cutx指定裁减的内容不存在"
        end if
end sub

'按指定首尾字符串位置偏移指针对偷取的内容进行裁减/方法
public sub cutby(head,headcusor,bot,botcusor) 
'参数分别是首字符串,首偏移值,尾字符串,尾偏移值,左偏移用负值,偏移指针单位为字符数
if isget_= false then call steal()
        if instr(value_,head)>0 and instr(value_,bot)>0 then
            value_=mid(value_ ,instr(value_ ,head)+len(head)+headcusor,instr(value_ ,bot)-1+botcusor-instr(value_ ,head)-len(head)-headcusor)
        else
            value_= "函数cutby指定裁减内容不存在"
        end if
end sub

'按指定首尾字符串对偷取的内容用新值进行替换(不包括首尾字符串)/方法
public sub filt(head,bot,str) '参数分别是首字符串,尾字符串,新值,新值位空则为过滤
if isget_= false then call steal()
        if instr(value_,head)>0 and instr(value_,bot)>0 then
            value_=replace(value_,mid(value_ ,instr(value_ ,head)+len(head) , instr(value_ ,bot)-instr(value_ ,head)-len(head)),str)
        else
            value_= "函数filt指定替换的内容不存在"
        end if
end sub

'按指定首尾字符串对偷取的内容用新值进行替换(包括首尾字符串)/方法
public sub filtx(head,bot,str) '参数分别是首字符串,尾字符串,新值,新值为空则为过滤
if isget_= false then call steal()
        if instr(value_,head)>0 and instr(value_,bot)>0 then
              value_=replace(value_,mid(value_ ,instr(value_ ,head),instr(value_ ,bot)-instr(value_ ,head)+len(bot)),str)
        else
            value_= "函数filtx指定替换的内容不存在"
        end if
end sub

'按指定首尾字符串位置偏移指针对偷取的内容新值进行替换/方法
public sub filtby(head,headcusor,bot,botcusor,str) 
'参数分别是首字符串,首偏移值,尾字符串,尾偏移值,新值,左偏移用负值,偏移指针单位为字符数,新值为空则为过滤
if isget_= false then call steal()
        if instr(value_,head)>0 and instr(value_,bot)>0 then
            value_=replace(value_ ,mid(value_ ,instr(value_ ,head)+len(head)+headcusor,instr(value_ ,bot)-1+botcusor-instr(value_ ,head)-len(head)-headcusor),str)
        else
            value_= "函数filtby指定替换的内容不存在"
        end if
end sub

'对符合条件的内容进行分块采集并组合,最终内容为以隔断的大文本/方法
'通过属性value得到此内容后你可以用split(value,"")得到你需要的数组
public sub rebuild(str) '参数是你目标页面反复出现的特征字符
if isget_= false then call steal()
value_= replace(value_,str,vbcrlf&""&vbcrlf)
end sub

'类排错模式——在类释放之前应用此方法可以随时查看你截获的内容html代码和页面显示效果/方法
public sub debug()
dim tempstr
tempstr=" "&value_&"

      "
response.write(tempstr)
end sub
end class
%>

相关文章