我在excel中创建一个宏,它应该从不同的网站中提取实时数据。我已经能够解决密码保护投资网站的问题,并认为从其他网站提取信息很容易。
那就是它!我只是想从网页中提取某些值并将其粘贴到excel中。
该网页为https://coinmarketcap.com/,我想知道像#34; Market Cap"," Price"等信息。和"姓名"。
Sub TestCoinCap()
Range("C3:F7").Clear
'Just naming the cells in excel
Range("C2").Value = "Market Cap"
Range("D2").Value = "Price"
Range("E2").Value = "Volume"
Range("B3").Value = "Ethereum"
Range("B4").Value = "Litecoin"
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "https://coinmarketcap.com/"
Do Until .ReadyState = 4
DoEvents
Loop
Dim dd As Double, de As Double, df As Double, dg As Double, di As
Double, dj As Double, dk As Double, dl As Double
Dim dn As Single, dp As Single, dq As Single, dr As Single, dt As
Single, du As Currency, dv As Currency, dw As Single
'Get Market Cap and save it as dd/de (cell nr. 3 in the array)
dd = IE.Document.getElementById("id-ethereum").Cells(3).innerText
de = IE.Document.getElementById("id-litecoin").Cells(3).innerText
'Write out the given information in cell C3 and C4
Range("C3").Value = dd
Range("C4").Value = de
上面你可以看到我的代码,它在其他网站上完美运行。我在HTML中错过了哪些内容?
感谢您的回复。
最好的关注 托马斯