以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何判断网页是否可以访问 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=142660) |
-- 作者:foxor -- 发布时间:2019/11/3 8:58:00 -- 如何判断网页是否可以访问 请教:如何判断一个网页是否存在和可以访问? |
-- 作者:有点蓝 -- 发布时间:2019/11/3 20:43:00 -- 比如 Dim hc As New HttpClient("http://127.0.0.1/index.htm") Dim ret as string = hc.GetData(true) if hc.RCookies("error") > "" then msgbox("无法访问:" & hc.RCookies("error")) end if
|
-- 作者:foxor -- 发布时间:2019/11/4 15:30:00 -- 谢谢!
用下面代码测试了一下,提示错误“给定关键字不在字典中”
Dim hc As New HttpClient("https://www.foxtable.com")
Dim ret As String = hc.GetData(True)
If hc.RCookies("error") > "" Then
msgbox("无法访问:" & hc.RCookies("error"))
End If
|
-- 作者:有点蓝 -- 发布时间:2019/11/4 15:57:00 -- If hc.RCookies.ContainsKey("error") AndAlso hc.RCookies("error") > "" Then msgbox("无法访问:" & hc.RCookies("error"))
|
-- 作者:foxor -- 发布时间:2019/11/4 21:09:00 -- 这回ok了,非常感谢有点蓝老师! |