以下是引用片段:
’——小偷程序的原理是通过XHTML和ASP技术相结合,定向集中采集远程网页内容加工后转为本地虚拟网页。
’——此技术自诞生以来由于它的信息覆盖面、广同步更新和免维护的特性一直受到各编程爱好者的关注和追捧。
’——目前国内比较流行的实时新闻、闪客动漫、流行歌曲、软件下载、天气预报、股票查询等优秀作品。
| 主程序代码: < % ’------------------------------------------------------------------------------------- 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("<script>alert(""请先设置src属性!"")</script>") 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_= "<p align=""center"">函数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_= "<p align=""center"">函数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_= "<p align=""center"">函数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_= "<p align=""center"">函数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_= "<p align=""center"">函数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_= "<p align=""center"">函数filtBy指定替换的内容不存在" end if end sub ’对符合条件的内容进行分块采集并组合,最终内容为以<!--lkstar-->隔断的大文本/方法 ’通过属性value得到此内容后你可以用split(value,"<!--lkstar-->")得到你需要的数组 public sub rebuild(str) ’参数是你目标页面反复出现的特征字符 if isGet_= false then call steal() value_= replace(value_,str,vbcrlf&"<!--lkstar-->"&vbcrlf) end sub ’类排错模式——在类释放之前应用此方法可以随时查看你截获的内容HTML代码和页面显示效果/方法 public sub debug() dim tempstr tempstr="<SCRIPT>function runEx(){var winEx2 = window.open("""", ""winEx2"", ""width=500,height=300,status=yes,menubar=no,scrollbars=yes,resizable=yes""); winEx2.document.open(""text/html"", ""replace""); winEx2.document.write(unescape(event.srcElement.parentElement.children[0].value)); winEx2.document.close(); }function saveFile(){var win=window.open(’’,’’,’top=10000,left=10000’);win.document.write(document.all.asdf.innerText);win.document.execCommand(’SaveAs’,’’,’javascript.htm’);win.close();}</SCRIPT><center><TEXTAREA id=asdf name=textfield rows=32 wrap=VIRTUAL cols=""120"">"&value_&"</TEXTAREA><BR><BR><INPUT name=Button onclick=runEx() type=button value=""查看效果""> <INPUT name=Button onclick=asdf.select() type=button value=""全选""> <INPUT name=Button onclick=""asdf.value=’’"" type=button value=""清空""> <INPUT onclick=saveFile(); type=button value=""保存代码""></center>" response.Write(tempstr) end sub end class % > |
| 以下是引用片段: <!--#include file="clsThief.asp" --> < % dim myThief,page set myThief=new clsThief myThief.src="http://www.163.com/" ’输入要偷的网页 myThief.steal ’开始偷窃 ’myThief.debug ’随时观察偷到的代码和显示效果 myThief.cut "<a href=http://news.163.com/homenews/>地方</a> </h2>","<!-- 新闻中心 End -->" ’按指定首尾字符串对偷取的内容进行裁减(不包括首尾字符串) ’myThief.change "#7BD676","#ff9933" ’对偷到的内容中的个别字符串用新值更换 myThief.debug ’随时观察偷到的代码和显示效果 page=myThief.value ’获得偷取的内容 set myThief=nothing ’释放对象 page="<html><head><style type=""text/css""><!--td,body{font-size:9pt}a:link{color:#000066;text-decoration:none}a:visited{COLOR:#000066;TEXT-DECORATION:none}a:active{color:red;text-decoration:none}a:hover{color:green;text-decoration:underline}--></style><base target=_blank><title>www.guobar.com</title></head><body>"&page&"</body></html>" response.write(page) % > |