• 生成静态页面的vbscript


    On Error Resume Next   
    Const ForWriting = 2   
    set args = Wscript.Arguments
    strURL 
    = args(0)
    strOutputFileName 
    = args(1)
    strEncode 
    = args(2)
    Set xmlHttp = CreateObject("MSXML2.XMLHTTP")     
    xmlHttp.setTimeouts 
    10000,10000,10000,30000            '设置超时(毫秒) 解析响应时间,连接响应时间,发送数据响应时间,接受数据响应时间
    xmlHttp.Open "GET", strURL, FALSE 
    xmlHttp.Send
    if xmlHttp.ReadyState = 4 then                        '接收到全部数据
        if xmlHttp.Status = 200 then                    '状态正常
            html = BytesToBstr(xmlHttp.ResponseBody,strEncode)
            
    if instr(html,"错误序列号"= 0 then        '检查是否有页面有错误
                Set objFSO = CreateObject("Scripting.FileSystemObject")   
                
    Set objFile = objFSO.CreateTextFile(strOutputFileName,   ForWriting)   
                objFile.Write html  
                objFile.Close
            
    end if
        
    end if
    end if

    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

    调用方法 参数分别人 源地址 生成文件名 编码

    set a=CreateObject("wscript.shell")

    a.run "BuildHtml.vbs http://www.baidu.com index.html GB2312",0

    wscript.quit

  • 相关阅读:
    (转发)storm 入门原理介绍
    shell :将标准输出及标准错误输出写到指定文件
    shell循环(两个日期比较,改变某个特定日期来改变当前比较值)
    MongoDB基本操作
    (转)cenntos 安装mongodb
    通过spark sql 将 hdfs上文件导入到mongodb
    股票实战--线性回归
    Python PIL 的image类和numpy array之间的互换
    根据关键点的脸型的计算
    用反卷积(Deconvnet)可视化理解卷积神经网络还有使用tensorboard
  • 原文地址:https://www.cnblogs.com/Death/p/1969092.html
Copyright © 2020-2023  润新知