dimanche 9 mai 2021

Web scraping using excel vba (Yahoo Finance)

I am currently trying to select a tabindex (calendar). I tried everything, but I cannot make it work. I would truly appreciate all the help. I am trying to change the time period to 5 years, and the frequency to monthly. I'd truly appreciate anyone's help. Thank you

Here is the link https://finance.yahoo.com/quote/GOOG/history?p=GOOG

Sub stock()


Dim ie As New SHDocVw.InternetExplorer
Dim dc As HTMLDocument
ie.navigate ("https://finance.yahoo.com/")
ie.Visible = True

Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
Loop

Set dc = ie.document

Application.Wait Now() + #12:00:02 AM#


Dim search As MSHTML.IHTMLElement
Set search = dc.getElementById("yfin-usr-qry")
search.Focus
SendKeys ("google")
SendKeys ("{ENTER}")

Application.Wait Now() + #12:00:05 AM#


Dim hist As MSHTML.IHTMLElement
Set hist = dc.getElementsByClassName("Bdbw(3px)")(5)
hist.Click

Application.Wait Now() + #12:00:05 AM#



Aucun commentaire:

Enregistrer un commentaire