获取远程flash并保存到本地_ASP教程-查字典教程网
获取远程flash并保存到本地
获取远程flash并保存到本地
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:

复制代码 代码如下:

<%

'--------------------------------------------------------------

Dbname="../data/flash.mdb"'更改数据库文件位置,强烈建议更改为.asp的文件!

SetConn=Server.CreateObject("ADODB.Connection")

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

.Open"GET",url,False

.Send

GetURL=bytes2bstr(.responsebody)

iflen(.responsebody)<100then

response.write"获取远程文件<ahref="&url&"target=_blank>"&url&"</a>失败。"

response.write"<metahttp-equiv=""refresh""content=""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

.Open"GET",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="http://www.gameyes.com/swf/"&flashId&".htm"

Html=GetURL(Url)

num=len(html)

ifnum<600then

response.write"<fontcolor=red>FLASH序号:</font>"&gourl1

response.write"此页不存在,跳转下一个........<metahttp-equiv=""refresh""content=""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="http://www.gameyes.com/smallpic"&pic1

pictype=right(pic,4)

flashurl=GetKey(Html,"download.asp?id="&flashId&"&swf=","""><imgsrc=")

flashurl=replace(flashurl,"http://old.gameyes.com/flash","http://60.191.9.222/flash")

flashurl="http://old.gameyes.com/flash"&flashurl

flashname=GetKey(Html,"<title>","小游戏休闲小游戏网gameyes.com</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")="yes"then

response.write"开始下载FLASH<br>"

response.flush

result=SaveRemoteFile("../flashfile/"&request("id")&".swf",""&flashurl&"")

IfresultThen

Response.Write"<b>FLASH下载成功——保存在<ahref=../flashfile/"&request("id")&".swftarget=_blank>flashfile/"&request("id")&".swf</a><br>"

Else

Response.Write"<b>FLASH保存失败</b><br>"

EndIf

endif

ifrequest("download")="yes"then

response.write"开始下载FLASH图片<br>"

response.flush

result=SaveRemoteFile("../flashpic/"&request("id")&pictype&"",""&pic&"")

IfresultThen

Response.Write"<b>FLASH图片下载成功——保存在<ahref=../flashpic/"&request("id")&pictype&"target=_blank>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.Open"driver={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")="yes"then

rs("flashurl")="../flashfile/"&request("id")&".swf"

else

rs("flashurl")=flashurl

endif

rs("nclass")=NClassID

rs("classid")=classid

rs("classname")=classname

ifrequest("download")="yes"then

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=""refresh""content=""0;URL=getid.asp?id="&gourl&"&overid="&request("overid")&"&download="&request("download")&""">"

%>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新ASP教程学习
    热门ASP教程学习
    编程开发子分类