ヤフー株価を取得するVBAを書いています。
ヤフー株価を取得するVBAを書いています。 メッセージボックスで会社名、株価を出力する例だと、下記の通りになりますが、2番目、3番目の前に何か処理を入れないと、うまく表示されません。これを回避する方法はあるでしょうか? ーーーー Sub 株価() Dim httpReq As XMLHTTP60 Dim htmlDoc As Object Set httpReq = New XMLHTTP60 httpReq.Open "GET", "https://finance.yahoo.co.jp/quote/8306.T" httpReq.send Do While httpReq.readyState < 4 DoEvents Loop Set htmlDoc = New HTMLDocument htmlDoc.write httpReq.responseText MsgBox "" ’これがないとエラーになる MsgBox htmlDoc.getElementsByClassName("_6uDhA-ZV")(0).innerText MsgBox htmlDoc.getElementsByClassName("_3rXWJKZF")(0).innerText End Sub
Visual Basic | プログラミング・65閲覧