获取远程flash并保存到本地
2018-09-06 12:24
复制代码 代码如下:
<%
--------------------------------------------------------------
Dbname=../data/flash.mdb更改数据库文件位置,强烈建议更改为.asp的文件!
Connstr=Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&Server.Mappath(Dbname)
Conn.OpenConnstr
------------------------------------------------------------
SetList=Conn.Execute(Select*FromSystem)
WebName=List(WebName)
WebUrl=List(WebUrl)
webemail=List(webemail)
zzname=List(zzname)
qq=List(webqq)
%>
<%
Server.ScriptTimeOut=999999999
%>
<%
ifrequest(overid)=then
response.write结束ID不可为空
response.end
elseifrequest(download)=then
response.write请选择是否下载
response.end
endif
ifrequest(id)=request(overid)then
response.write采集任务结束
response.end
endif
gourl1=request(id)
gourl1=gourl1+1
%>
<%
functionGetPy(Str)
fori=1tolen(Str)
GetPy=GetPy&GetPyChar(mid(Str,i,1))
next
endfunction
FunctionGetURL(url)
SetRetrieval=CreateObject(Microsoft.XMLHTTP)
WithRetrieval
.OpenGET,url,False
.Send
GetURL=bytes2bstr(.responsebody)
iflen(.responsebody)<100then
response.write获取远程文件<ahref=&url&>&url&</a>失败。
response.write<metahttp-equiv=refreshcontent=0;URL=getid.asp?id=&gourl1&>
response.end
endif
EndWith
SetRetrieval=Nothing
EndFunction
functionbytes2bstr(vin)
strreturn=
fori=1tolenb(vin)
thischarcode=ascb(midb(vin,i,1))
ifthischarcode<&h80then
strreturn=strreturn&chr(thischarcode)
else
nextcharcode=ascb(midb(vin,i+1,1))
strreturn=strreturn&chr(clng(thischarcode)*&h100+cint(nextcharcode))
i=i+1
endif
next
bytes2bstr=strreturn
endfunction
FunctionGetKey(HTML,Start,Last)
filearray=split(HTML,Start)
filearray2=split(filearray(1),Last)
GetKey=filearray2(0)
EndFunction
------------------------------------
FunctionSaveRemoteFile(s_LocalFileName,s_RemoteFileUrl)
DimAds,Retrieval,GetRemoteData
DimbError
bError=False
SaveRemoteFile=False
OnErrorResumeNext
SetRetrieval=Server.CreateObject(Msxml2.ServerXMLHTTP)
WithRetrieval
.OpenGET,s_RemoteFileUrl,False
.Send
If.Status=200Then
GetRemoteData=.ResponseBody
Else
bError=True
EndIf
EndWith
SetRetrieval=Nothing
IfNotbErrorThen
SetAds=Server.CreateObject(Adodb.Stream)
WithAds
.Type=1
.Open
.WriteGetRemoteData
.SaveToFileServer.MapPath(s_LocalFileName),2
.Cancel()
.Close()
EndWith
SetAds=nothing
EndIf
IfErr.Number=0AndNotbErrorThen
SaveRemoteFile=True
Else
Err.Clear
EndIf
EndFunction
%>
<%
flashId=Request(Id)
Url=
Html=GetURL(Url)
num=len(html)
ifnum<600then
response.write<fontcolor=red>FLASH序号:</font>&gourl1
response.write此页不存在,跳转下一个........<metahttp-equiv=refreshcontent=0;URL=getid.asp?id=&gourl1&&overid=&request(overid)&&download=&request(download)&>
response.end
endif
nclassid1=GetKey(Html,FLASH游戏>><aclass=ahref=../list/a_,.htm>)
nclass=GetKey(Html,<aclass=ahref=../list/a_&nclassid1&.htm>,</a>)
nclass=nclass&类
classid1=GetKey(Html,class=ahref=../list/,.htm>)
classname=GetKey(Html,class=ahref=../list/&classid1&.htm>,</a>)
body=GetKey(Html,<divid=view_intro>,</div>)
body=replace(body,<tr>,)
body=replace(body,<td>,)
pic1=GetKey(Html,#secrt{background:url(../smallpic,)22no-repeat;border:1px)
pic1=replace(pic1,_b.gif,.gif)
pic1=replace(pic1,_b.jpg,.jpg)
pic=
pictype=right(pic,4)
flashurl=GetKey(Html,download.asp?id=&flashId&&swf=,><imgsrc=)
flashurl=replace(flashurl,
flashurl=
flashname=GetKey(Html,<title>,小游戏休闲小游戏网lt;/title>)
%>
<%
response.write<fontcolor=red>FLASH序号:</font>&gourl1
response.write<br>
response.write<fontcolor=red>FLASH名称:</font>&flashname
response.write<br>
response.write<fontcolor=red>所属大类:</font>&nclass
response.write<br>
response.write<fontcolor=red>所属二类:</font>&classname
response.write<br>
response.write<fontcolor=red>游戏介绍:</font>&body
response.write<br>
response.write<fontcolor=red>游戏小图:</font>&pic
response.write<br>
response.write<fontcolor=red>FLASH地址:</font>&flashurl
response.write<br>
%>
<%
ifrequest(download)=yesthen
response.write开始下载FLASH<br>
response.flush
result=SaveRemoteFile(../flashfile/&request(id)&.swf,&flashurl&)
IfresultThen
Response.Write<b>FLASH下载成功——保存在<ahref=../flashfile/&request(id)&.swf>flashfile/&request(id)&.swf</a><br>
Else
Response.Write<b>FLASH保存失败</b><br>
EndIf
endif
ifrequest(download)=yesthen
response.write开始下载FLASH图片<br>
response.flush
result=SaveRemoteFile(../flashpic/&request(id)&pictype&,&pic&)
IfresultThen
Response.Write<b>FLASH图片下载成功——保存在<ahref=../flashpic/&request(id)&pictype&>flashpic/&request(id)&pictype&</a>
Else
Response.Write<b>FLASH图片保存失败</b><br>
response.write此FLASH采集完毕,继续采集下一个<br><hr>
EndIf
endif
%>
<%
DBPath=Server.MapPath(../data/flash.mdb)
setConn=server.createobject(adodb.connection)
conn.Opendriver={MicrosoftAccessDriver(*.mdb)};dbq=&DBPath
setrs=server.CreateObject(ADODB.RecordSet)
Sql=Select*FromclassWherename=&nclass&
Rs.OpenSql,Conn,1,3
IfRs.EofAndRs.BofThen
Rs.AddNew
EndIf
rs(name)=nclass
rs(classid)=0
Rs.Update
Rs.Close
SetRs=Nothing
Setrsc=Conn.Execute(select*fromclasswherename=&nclass&)
nclassid=rsc(id)
rsc.close
setrsc=nothing
处理FLASH的二级类别,如数据库中没有该类别,则增加
setrst=server.CreateObject(ADODB.RecordSet)
Sql=Select*FromclassWherename=&classname&
Rst.OpenSql,Conn,1,3
IfRst.EofAndRst.BofThen
Rst.AddNew
EndIf
rst(name)=classname
rst(classid)=nclassid
Rst.Update
Rst.Close
SetRst=Nothing
取类别的ID号
Setrsc=Conn.Execute(select*fromclasswherename=&classname&)
classid=rsc(id)
rsc.close
setrsc=nothing
===================================================
可以开始写入flash
setrs=server.CreateObject(ADODB.RecordSet)
Sql=Select*FromflashWhereflashname=&flashname&andflashurl=&flashurl&
Rs.OpenSql,Conn,1,3
IfRs.EofAndRs.BofThen
Rs.AddNew
EndIf
rs(flashname)=flashname
ifrequest(download)=yesthen
rs(flashurl)=../flashfile/&request(id)&.swf
else
rs(flashurl)=flashurl
endif
rs(nclass)=NClassID
rs(classid)=classid
rs(classname)=classname
ifrequest(download)=yesthen
rs(pic)=../flashpic/&request(id)&pictype
else
rs(pic)=pic
endif
rs(size)=500kb
rs(sj)=now()
rs(body)=body
rs(tj)=no
rs(hot)=1
rs(user)=admin
rs(zz)=未知
rs(geshou)=不祥
Rs.Update
Rs.Close
SetRs=Nothing
conn.close
setconn=nothing
%>
<%
dimgourl
gourl=flashId+1
response.write<metahttp-equiv=refreshcontent=0;URL=getid.asp?id=&gourl&&overid=&request(overid)&&download=&request(download)&>
%>