如何从另一个网站下载文件 [英] how to download file from another website
问题描述
你好,
我正在浏览登录另一个网站的Web应用程序,然后只需单击一个按钮即可从该网站下载一些文件.
我已经实现了登录该网站的逻辑,还能够查看该网站的受保护页面.
现在,该网站返回的HTML代码的文件名我想在< script>下下载.标签
< script> PrintFileURL("13572_BranchInformationReport_2012-05-22.zip","13572_BranchInformationReport_2012-05-22.zip",0,"184601","May 22 1:30","/icons/default.gif")< ;/script>
被称为
的方法
Hello,
I m woking on a web application that logins on another website and then downloads some files from that site just on a click of a button.
I have already implemented the logic to login on that website and am also able to see the protected page of that site.
Now that website is returning an HTML code that has the filename i want to download under <script> tag
<script>PrintFileURL("13572_BranchInformationReport_2012-05-22.zip","13572_BranchInformationReport_2012-05-22.zip",0,"184601","May 22 1:30","/icons/default.gif")</script>
the method called is
function PrintFileURL(uri, name, dirFlag, filesize, time, icon)
{
var color
var bgcolor
if(!(name.length>2 && name.charAt(name.length-1)=="e" && name.charAt(name.length-2)==".")) {
if (lineColor)
{
bgcolor="EEEEEE"
lineColor=false
}
else
{
bgcolor="FFFFFF"
lineColor=true
}
document.write("<tr bgcolor=" + bgcolor + ">");
if (dirFlag)
{
document.write("<td nowrap=""><img src='" + icon + "'><a href="" + uri +<br mode="hold" /> "/?T"> " + name + "</a></td>");
document.write("<td> </td>");
document.write("<td> </td>");
document.write("<td> </td>");
}
else
{
document.write("<td nowrap=""><img src='" + icon + "'><a href="" + uri +<br mode="hold" /> ""> " + name + "</a></td>");
document.write("<td><font face="Arial" size="2">" + filesize +
"</font></td>");
document.write("<td><font face="Arial" size="2">" + time +
"</font></td>");
document.write("<td> </td>");
}
document.write("</tr>");
}
}
我完全被困在这里.有人可以帮忙吗?
在此先感谢
问候,
Akhil
I am totally stuck here. Can someone help.
Thanks in advance
Regards,
Akhil
推荐答案
在这里您看到代码
Here you see the code
public void downloadFile(string Url, string filePath)
{
if (File.Exists(filePath))
{
File.Delete(filePath);
}
//Downloading file form Http Url
WebClient myWebClient = new WebClient();
myWebClient.DownloadFile(url, filePath);
//CompleteDownloading file form Http Url
}
在上面的代码中,代替url =,"13572_BranchInformationReport_2012-05-22.zip",0,"184601","May 22 1:30","/icons/default.gif"并在文件路径中将路径设置为保存下载文件
}
In the above code ,In place of url=,"13572_BranchInformationReport_2012-05-22.zip",0,"184601","May 22 1:30","/icons/default.gif" and in filepath put the path to save the download file
这篇关于如何从另一个网站下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!