gpt4 book ai didi

vba - 在 VBA Excel 中读取 HTML 文件

转载 作者:行者123 更新时间:2023-12-04 21:53:04 27 4
gpt4 key购买 nike

我想阅读 VBA 中的 HTML 代码(类似于 Java 中的 URL)。我需要将它保存在一个字符串中。我之后解析它。

阿尔潘67

最佳答案

这是为您准备的功能。它将返回由给定 URL 返回的 HTML 的字符串。

Function GetHTML(URL As String) As String
Dim HTML As String
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
GetHTML = .ResponseText
End With
End Function

只需确保您提供的 URL 格式正确。 IE。如果合适,它包括 http://https://

例如:GetHtml("www.google.com") 不正确。
你会想要 GetHtml("https://www.google.com/")

关于vba - 在 VBA Excel 中读取 HTML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14103220/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com