zoukankan      html  css  js  c++  java
  • VBA提取HTML文件信息

    Sub test()
        Dim html As Object, D As Object, W As Object, arr()
        Set html = CreateObject("msxml2.xmlhttp")
        html.Open "GET", "file:///" & ThisWorkbook.Path & "内参平台.html", False
        html.send: strhtml = html.responseText
        Set D = CreateObject("htmlfile"): Set W = D.parentWindow
        D.write "<script src='http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js'></script><body></body>"
        D.body.innerHtml = strhtml
        W.execScript "a=[];$('div.time').each(function(){a.push($(this).text())});r=a.length;"
        W.execScript "b=[];$('div.time').siblings().filter('p').each(function(){b.push($(this).text())});c=b.length;"
        ReDim arr(1 To W.r, 1 To 2)
        For i = 0 To W.r - 1
            arr(i + 1, 1) = W.eval("a[" & i & "]")
            arr(i + 1, 2) = W.eval("b[" & i & "]")
        Next
        Cells.Clear
        [a:a].NumberFormatLocal = "h:mm;@"
        Range("a2").Resize(UBound(arr), 2) = arr
    End Sub

  • 相关阅读:
    spring boot 报错 Failed to read HTTP message
    spring boot 之 Mybatis 配置
    Java生成xlsx格式的excel文件
    遍历FTP目录及下载
    Spring 报错
    git ssh key生成
    spring mvc原理
    LightOJ 1154
    Light OJ 1153
    入栈出栈的顺序问题
  • 原文地址:https://www.cnblogs.com/shida-liu/p/9396395.html
Copyright © 2011-2022 走看看