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

  • 相关阅读:
    Typescript 最佳实践
    《三》大话 Typescript 接口
    二. 细说小程序登陆
    一. 优化小程序自身的Storage
    开始你的第一个npm脚本工具
    javascript 玩转Date对象
    createjs 小游戏开发实战
    前端实现连连看小游戏(1)
    一篇文章带你快速入门createjs
    从0到1完成小程序开发(4)
  • 原文地址:https://www.cnblogs.com/Death/p/1969092.html
Copyright © 2011-2022 走看看