我有一个应该检查url是否存在的函数。
Function URLExists(URL As String) As Boolean
Dim HttpWebRequest_ As HttpWebRequest = WebRequest.Create(URL)
HttpWebRequest_.Method="HEAD" 'It doesn't work even without this.
Dim HttpWebResponse_ As HttpWebResponse = HttpWebRequest_.GetResponse()
Return HttpWebResponse_.StatusCode = HttpStatusCode.OK
End Function
如果我尝试 URLExists(" http://www.google.com/thisPageDoesNotExistAndIsRetarded.html "),它返回 True,如果我尝试 URLExists(" https://www.google.com/ "),(显然存在),它返回 True,(正确)。谢谢。