zoukankan      html  css  js  c++  java
  • 生成静态页面的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

  • 相关阅读:
    2020北航OO第二单元总结
    2020北航OO第一单元总结
    OO结课了,狂喜
    BUAAOO第三单元总结
    BUAAOO第二单元代码分析
    BUAAOO第一单元代码分析
    OO第四次博客作业
    OO第三次博客作业
    OO第二次博客作业
    OO第一次博客作业
  • 原文地址:https://www.cnblogs.com/Death/p/1969092.html
Copyright © 2011-2022 走看看