一小偷类!!有兴趣的可以看看

2018-09-06 11:02

阅读:638

  类代码(cls.asp)
<%

ClassclsThief

PrivatestrUrl偷取地址
PrivatestrValue偷取的内容,所有内容
PrivatestrResult偷取结果,可以具体某一块内容
Privateflag是否已经偷过

-------初始化类--------
PrivateSubClass_Initialize()
strUrl=
strValue=
strResult=
flag=false
EndSub

------类结束-----------
PrivateSubClass_Terminate()
EndSub

------初始化url属性----
PublicPropertyLeturl(ByValiurl)
strUrl=iurl
EndProperty

------返回输出内容----
publicpropertygetvalue
value=strValue
endproperty

publicpropertygetresult
result=strResult
endproperty

------------文字处理-----------
privateFunctionBytesToBstr(body,Cset)
dimobjstream
setobjstream=Server.CreateObject(adodb.stream)
objstream.Type=1
objstream.Mode=3
objstream.Open
objstream.Writebody
objstream.Position=0
objstream.Type=2
objstream.Charset=Cset
BytesToBstr=objstream.ReadText
objstream.Close
setobjstream=nothing
EndFunction

-------文字处理-------
privateFunctionIchange(str)
DimfinalStr
DimicharCode
DiminextCode
Fori=1Tolenb(str)
icharCode=ascb(midb(str,i,1))
IficharCode<&H80Then
finalStr=finalStr&chr(icharCode)
Else
inextCode=ascb(midb(str,i+1,1))
finalstr=finalstr&chr(clng(icharCode)*&H100+cint(inextCode))
i=i+1
EndIf
Next
Ichange=finalStr
EndFunction

-------内容抓取--------
PublicsubSeize()
ifstrUrl<>then
dimiconnect
Seticonnect=CreateObject(Microsoft.XMLHTTP)
iconnect.openGET,strUrl,false
iconnect.send()

strValue=BytesToBSTR(iconnect.responseBody,GB2312)
flag=true
seticonnect=nothing
iferr.number<>0thenerr.Clear
else
response.write(请设置url的属性,即url地址)
endif
endsub

------内容分析------
PublicsubAssay(head,headCusor,bot,botCusor)
ifflag=falsethencallSeize()
ifinstr(strValue,head)andinstr(strValue,bot)then
diminum
inum=len(strValue)-instr(strValue,head)-len(head)-headCusor
strValue=right(strValue,inum)
inum=instr(strValue,bot)-1+botCusor
strResult=left(strValue,inum)
else
strResult=没有匹配到相关记录,请检查开始标记代码是否唯一
endif
endsub

----替换空格及回车行----
publicsubShift()
ifflag=falsethencallSeize()
strResult=replace(replace(strResult,vbCr,),vbLf,)
endsub

------对内容自定义替换----
PublicsubChange(oldStr,newStr)
ifflag=falsethencallSeize()
strResult=replace(strResult,oldStr,newStr)
endsub

--------自定义正则进行匹配---
publicsubpickByReg(patrn)
ifisGet_=falsethencallSeize()
dimtempReg,match,matches,content
settempReg=newRegExp
tempReg.IgnoreCase=true
tempReg.Global=true
tempReg.Pattern=patrn
setmatches=tempReg.execute(value_)
foreachmatchinmatches
content=content&match.value&<!--lkstar-->
next
strValue=content
setmatches=nothing
settempReg=nothing
endsub

--------如果有首页文件则转入-----------
PublicsubCheckFile(folderName,fileName)
dimurl
Setfs=Server.CreateObject(Scripting.FileSystemObject)
iffs.FolderExists(server.MapPath(./)&\&folderName&\&fileName)then
setfs=nothing
url=folderName&/&fileName
response.writeurl
response.redirecturl
endif
endsub

------生成文件------
PublicsubMakeFile(folderName,fileName)
Setfs=Server.CreateObject(Scripting.FileSystemObject)

iffolderName<>then
ifnotfs.FolderExists(server.MapPath(/&folderName&/))then
response.write文件不存在
fs.CreateFolder(folderName)
else
response.write文件存在
endif
endif

SetCrFi=fs.CreateTextFile(server.MapPath(./)&\&folderName&\&fileName)
Crfi.Writeline(strResult)
setCrFi=nothing
setfs=nothing
dimurl
url=folderName&/&fileName
response.redirecturl

endsub

-------查看偷出的代码----
publicsublook()
dimtempstr
response.Write(tempstr)
endsub

endclass
%>

引用页(test.asp)

<!--#IncludeFile=cls.asp-->
<%
dimmyThief,value
setmyThief=newclsThief实例化类
myThief.CheckFile,index.html检测是否已经偷过并生成
myThief.url=目标URL
myThief.Seize开始偷取
myThief.Assay<html>,-7,</html>,7剪切标记
myThief.Change择优,浪人进行替换
value=myThief.result最后得到的内容
myThief.MakeFile,index.html生成文件
setmyThief=nothing
response.writevalue
%>


评论


亲,登录后才可以留言!