使用WinHTTPRequest读取本地HTML文件 [英] Read Local HTML File using WinHTTPRequest

查看:66
本文介绍了使用WinHTTPRequest读取本地HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以下代码

Sub myConSP()
    Dim oHtmlSP As HTMLDocument
    Dim tSPIndex As HTMLDivElement
    Dim tSPIdx As HTMLDivElement
    Dim tables As Object
    
    Set oHtmlSP = New HTMLDocument
    With CreateObject("WINHTTP.WinHTTPRequest.5.1")
        .Open "GET", "C:\Users\Future\Desktop\Test.html", False
        .send
        oHtmlSP.body.innerHTML = .responseText
    End With
    Set tables = oHtmlSP.querySelectorAll("table[width='100%'] table:first-child")
    Debug.Print tables.Length
End Sub

我尝试了不同的方法来通过该代码读取HTML本地文件.如何用这样的代码引用本地文件HTML文件?

I tried different ways to read the HTML local file through that code. How can I refer to the local file HTML file in such a code?

推荐答案

我认为您过于复杂.

尝试:

Sub myConSP()
    Dim oHtmlSP As HTMLDocument

Set oHtmlSP = New HTMLDocument
oHtmlSP.body.innerHTML = "full_path"

'process the file
End Sub

这篇关于使用WinHTTPRequest读取本地HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆