在这种情况下,问题是ssl连接协商失败。如果您不使用ssl进行连接对您没有任何影响,我只会使用以下方法:
Private Sub DownloadImage(ByVal source As String, destination As String)
If source.StartsWith("https://") Then source = source.Replace("https://", "http://")
Using wc As New System.Net.WebClient
wc.DownloadFile(source, destination)
End Using
End Sub
如果必须使用ssl,请尝试将TLS版本设置为1.2,因为某些网站需要,并且。net web client不默认为:
Private Sub DownloadImage(ByVal source As String, destination As String)
System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
Using wc As New System.Net.WebClient
wc.DownloadFile(source, destination)
End Using
End Sub
调用时使用:
DownloadImage("https://www.oglf.org/wp-content/uploads/2017/12/BestLEDTeethWhitening.jpg", _
"c:/tmp/test.jpg")