如何在允许下载前从http服务器下载需要转介的文件?
问题描述:
我通常使用以下代码下载文件:如何在允许下载前从http服务器下载需要转介的文件?
My.Computer.Network.DownloadFile("url of the file","filepath to save the file")
但最近我遇到了一个网站,只允许文件下载,如果你从它的网站点击它,而不是通过从vb.net代码直接下载。
我的问题是:如何从允许下载之前需要推荐的http服务器下载文件?
答
尝试增加手动Referer标头:
WebClient wc = new WebClient();
wc.Headers.Add("Referer","http://whatever.com");
wc.DownloadFile("url of the file","filepath to save the file");
+0
+1感谢您的帮助。有用! – user774411
你为什么要举报此vb.net和C#?您的代码似乎是VB.NET – Icarus
@Icarus:我可以使用代码转换器转换为VB.NET – user774411