110,536
社区成员
发帖
与我相关
我的任务
分享
Do
Try
sUrl = "https://download.lfd.uci.edu/pythonlibs/o4uhg4xd/tensorflow-1.9.0-cp36-cp36m-win_amd64.whl"
xmlhttp = DirectCast(WebRequest.Create(sUrl), HttpWebRequest)
xmlhttp.KeepAlive = False : xmlhttp.AllowAutoRedirect = False
xmlhttp.Timeout = 9000 : xmlhttp.ReadWriteTimeout = 1
xmlhttp.Method = "GET"
xmlhttp.Host = GetLinkHost(sUrl)
xmlhttp.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
xmlhttp.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
xmlhttp.Referer = "https://www.ifeng.com"
xmlhttp.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
'xmlhttp.Headers.Add("Accept-Encoding", "gzip, deflate")
Using rep As HttpWebResponse = xmlhttp.GetResponse()
Using reps As Stream = rep.GetResponseStream()
'dim bytes() as byte <-----此处不能定义
bytes = GetRepBytes(reps) '获取responseStream返回的字节数组
End Using
End Using
Downbytes(bytes, AppPath() & "\1111.whl") : End '下载保存到文件并退出
Catch ex As WebException
If ex.Status = WebExceptionStatus.Timeout Then
msgbox(ex.StackTrace)
msgbox(ex.Message)
End
Else
msgbox("other")
Exit Do
End If
Catch ex As Exception
msgbox(ex.Message)
msgbox(ex.StackTrace)
Exit Do
Finally
xmlhttp.Abort() : xmlhttp = Nothing
End Try
Loop
End