【问题标题】:Check URL exists or not By VBScript通过 VBScript 检查 URL 是否存在
【发布时间】:2017-02-01 10:59:03
【问题描述】:

我想要一个 vbscript,它可以在不打开任何浏览器的情况下检查 URL 是否存在。如果存在则弹出一条消息。 脚本模式应该是这样的:(更简单的脚本,最好的脚本)

这里是常用代码

Url="www.lol.com/letter.txt"

判断url是否存在的代码

If exists

Msgbox("Success")

Else

Msgbox("Failed")

Wscript.Quit

【问题讨论】:

    标签: url if-statement vbscript request exists


    【解决方案1】:

    这个函数应该可以完成这项工作

    function testUrl(url)
        Set o = CreateObject("MSXML2.XMLHTTP")
        on error resume next
        o.open "GET", url, False
        o.send
        if o.Status = 200 then testUrl = True
        on error goto 0 
    end function
    

    调用它使用

    if testUrl("http://www.example.com") then
         msgbox "SUCCESS"
    else
         msgbox "FAILED" 
    end if
    

    【讨论】:

    • 好兄弟...但是 avast 将此脚本检测为病毒.. :(
    • 你不能把它标记为异常吗?
    猜你喜欢
    • 1970-01-01
    • 2015-03-07
    • 2011-01-17
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 2011-05-09
    相关资源
    最近更新 更多