概述
GetFile.wsc
复制代码 代码如下:
<?xml version="1.0" encoding="gb2312"?>
<component>
<?component error="true" debug="true"?>
<public>
<property name="Referer" />
<property name="Content" />
<property name="Data" />
<method name="GetFile">
<parameter name="URL" />
</method>
<method name="Save">
<parameter name="Path" />
</method>
</public>
<implements type="Behavior">
<event name="ondowncomplete" />
</implements>
<object progid="Microsoft.XmlHttp" id="Http" />
<script language="javascript">
<![CDATA[
var Referer, Content, Data;
var Stream = new ActiveXObject("ADODB.Stream");
Stream.Type = 1;
function onReady()
{
if(Http.readyState == 4)
{
Content = Http.responseText;
Data = Http.responseBody;
fireEvent("ondowncomplete");
Http.abort();
}
}
function GetFile(URL)
{
Http.onreadystatechange = onReady;
Http.open("GET", URL, true, "", "");
if(Referer) Http.setRequestHeader("Referer", Referer);
Http.send(null);
}
function Save(Path)
{
Stream.Open();
Stream.Write(Data);
Stream.SaveToFile(Path, 2);
Stream.Close();
}
]]>
</script>
</component>
test.hta
复制代码 代码如下:
<html><head><script>
var Down = document.createElement("Comment");
document.lastChild.lastChild.appendChild(Down);
Down.style.behavior="url(GetFile.wsc)";
Down.ondowncomplete = function()
{
//document.write(Down.Content);
Down.Save(SaveTo.value);
Go.disabled=0;
alert("OK");
}
function GetFile()
{
Go.disabled = 1;
Down.Referer = Referer.value;
Down.GetFile(URL.value);
}
</script>
</head><body>
URL: <input id="URL" size="50" value="http://www.booksky.biz/SendFile.aspx?FileID=15531"><br>
Referer: <input name="Referer" size="40" value="http://www.booksky.biz"><br>
SaveTo: <input name="SaveTo" size="40" value="D:Test.gif"><br>
<input id="Go" type=button value="下载" onclick="GetFile()">
</body></html>
最后
以上就是羞涩电源为你收集整理的通过修改referer下载文件的方法的全部内容,希望文章能够帮你解决通过修改referer下载文件的方法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复