服务器定时任务vbs文件

该博客展示了如何利用VBScript编写一个函数sendsms,通过调用HTTP请求发送短信到指定手机号。函数中包含了HTTP请求的实现,以及对返回结果的处理。此外,还提供了辅助函数getHTTPPage用于获取HTTP页面内容,并对内容进行编码转换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

执行测试wscript xxx.vbs



ScriptTimeout=999999





function sendsms(byval phone, byval sms)
    
    dim r, url
    'url = "http://202.85.214.57:30002/shttp.recmt?ua=jhtx&pw=332006&mobile="&phone&"&msg="&sms '正式上线前修改UA和PW。
    url = "http://202.85.214.57:30002/shttp.recmt?ua=9hservice&pw=12345&mobile="&phone&"&msg="&sms '正式上线前修改UA和PW。
    r = getHTTPPage(url)
    r = lcase(r)  '"<root><result>1</result><i>0007715261</i></root>"
    r = replace(r,chr(10),"")
    r = replace(r,chr(13),"")
    r = replace(r," ","")
    r = replace(r,"<root><result>","")
    r = replace(r,"</i></root>","")
    r = replace(r,"</result></root>","")
    r = replace(r,"</result><i>","|")
    sendsms = r
    
    
end function













function getHTTPPage(url)
  dim Http
  set Http=createobject("MSXML2.ServerXMLHTTP.6.0")
  Http.setTimeouts 5000,5000,5000,10000
  Http.open "GET",url,false
  Http.send()
  If Http.ReadyState = 4 And Http.Status = 200 then
      getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
  else
      getHTTPPage=""
  end if
  set http=nothing
  if err.number<>0 then err.Clear 
end function
Function BytesToBstr(body,Cset)
      dim objstream
      set objstream = CreateObject("adodb.stream")
      objstream.Type = 1
      objstream.Mode = 3
      objstream.Open
      objstream.Write body
      objstream.Position = 0
      objstream.Type = 2
      objstream.Charset = Cset
      BytesToBstr = objstream.ReadText 
      objstream.Close
      set objstream = nothing
End Function

function getUrl(url)
    url = replace(url,"|","︱")
    getUrl = getHTTPPage(url)
    getUrl = replace(getUrl,chr(13)&chr(10),"")
    getUrl = replace(getUrl,chr(10)&chr(13),"")
    getUrl = replace(getUrl,chr(10),"")
    getUrl = replace(getUrl,chr(13),"")
    if instr(url,"prototype=14&type=3")<=0 and instr(url,"prototype=86&type=6")<=0 then
        getUrl = replace(getUrl," ","")
    end if
end function



call sendsms("13488802775","send Success")
call sendsms("18601152191","send Success")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值