Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

vb.net - Unable to download .zip file file from given link

I used to download .zip file from given link using vb.net code. But recently it stopped working and I get

System.Net.WebException: 'The operation has timed out

Below is my code:

 Dim strUrl As String
        strUrl = "http://www.nseindia.com/api/reports?archives=%5B%7B%22name%22%3A%22CM%20-%20Bhavcopy(csv)%22%2C%22type%22%3A%22archives%22%2C%22category%22%3A%22capital-market%22%2C%22section%22%3A%22equities%22%7D%5D&date=27-Jan-2021&type=equities&mode=single"
        Dim fileName As String
        fileName = "C:UsersmyNameDownloadsMyCustomerDownloadmyExcel.zip"
Dim wc As WebClient = New WebClient()

 wc.Headers("accept") = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
        wc.Headers("accept-language") = "en-US,en;q=0.9"
        wc.Headers("accept-encoding") = "gzip, deflate, br"
        wc.Headers("user-agent") = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36"
       
 wc.DownloadFile(strUrl, fileName)

It used to work before but suddenly stopped working. Did I need to add/update any other settings?

question from:https://stackoverflow.com/questions/65938798/unable-to-download-zip-file-file-from-given-link

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...