【发布时间】:2022-01-08 14:49:19
【问题描述】:
我试图从网站的静态页面中获取一个数字,但是当我执行 HTML 请求时,结果是一个奇怪的 HTML,没有我想要的原始 html 的信息。
我试图获取信息的网站是: https://fnet.bmfbovespa.com.br/fnet/publico/exibirDocumento?id=233361&cvm=true 但我可以得到相同的结果: https://fnet.bmfbovespa.com.br/fnet/publico/visualizarDocumento?id=233361&cvm=true
我要获取的数字是页面中的数字“0,05”
我的代码是:
Sub trying()
Dim html As HTMLDocument
Set html = New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "https://fnet.bmfbovespa.com.br/fnet/publico/exibirDocumento?id=233361&cvm=true&", False
.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" 'to deal with potential caching
.send
html.body.innerHTML = .responseText
End With
Set element = html.getElementsByTagName("td")(31).innerText
Sheets("Sheet1").Cells(1, 1) = element
End Sub
我也尝试过使用 InternetExplorer.Application 进行此操作,但问题仍然存在
【问题讨论】:
-
请阅读“How to Ask”、“Stack Overflow question checklist”、“minimal reproducible example”及其链接页面。当询问关于抓取的问题时,我们需要最少的 HTML 和代码来运行和复制问题在问题本身中。
标签: excel vba web-scraping