110,534
社区成员
发帖
与我相关
我的任务
分享
Public Function DownloadStringByURL(ByVal URL As String) As String
Dim errorCount As Integer = 0
Return PrivateDownloadStringByURL(URL, errorCount)
End Function
Private Function PrivateDownloadStringByURL(ByVal URL As String, ByRef errorCount As Integer) As String
Application.DoEvents()
Dim pageHtml As String = String.Empty
If (errorCount > 10) Then
Return pageHtml
End If
Try
Dim web As New WebClient
pageHtml = Encoding.UTF8.GetString(web.DownloadData(URL))
Catch ex As Exception
errorCount = errorCount + 1
pageHtml = PrivateDownloadStringByURL(URL, errorCount)
End Try
Return pageHtml
End Function
Try
Dim web As New WebClient
pageHtml = Encoding.UTF8.GetString(web.DownloadData(URL))
Catch ex As Exception
errorCount = errorCount + 1
pageHtml = PrivateDownloadStringByURL(URL, errorCount)
End Try