使用.NET webclient从nseindia下载Bhavcopy时出现错误,远程服务器返回错误:(403)禁止 [英] Bhavcopy download from nseindia using .NET webclient gives error the remote server returned an error: (403) forbidden

查看:78
本文介绍了使用.NET webclient从nseindia下载Bhavcopy时出现错误,远程服务器返回错误:(403)禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码来自codeproject中的一个线程会出错。

远程服务器返回错误:(403)禁止



文件可以使用下载管理器下载。



我尝试过:



Following code from one of the thread in codeproject gives error.
"The remote server returned an error: (403) Forbidden"

file can be downloaded using download manager.

What I have tried:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
Dim wc As New WebClient

Dim fileurl As String = "http://www.nseindia.com/content/historical/EQUITIES/2012/AUG/cm28AUG2012bhav.csv.zip"
Dim filelocation As String = "d:\aaaaa.zip"

wc.Headers("Accept") = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
wc.Headers("User-Agent") = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"

wc.DownloadFile(fileurl, filelocation)

Catch exception As Exception
MsgBox("CAnnot Download")
End Try
End Sub

推荐答案

执行消息告诉您的操作。或联系网站管理员寻求帮助。
Do what the message tells you. Or contact the site administrators for help.


这篇关于使用.NET webclient从nseindia下载Bhavcopy时出现错误,远程服务器返回错误:(403)禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆