georgiboy
07-02-2017, 05:38 AM
Hi all
Basically, this code runs a search on Google for a stock symbol and returns the aftermarket value along with the company name and market close value.
Everything works as it should but slowly.
Is there a faster method?
Sub WorkingWebScraper() Dim IE As Object, dd As Double, dv As Double, dc As String, rCell As Range
Sheet1.Range("B4:D88,I4:M24,O4:S24").ClearContents
Sheet1.Range("A1").Value = "Laste update: " & Now()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
On Error Resume Next
For Each rCell In Sheet1.Range(Sheet1.Range("A4"), Sheet1.Range("A4").End(xlDown)).Cells
IE.navigate "https://www.google.co.uk/search?q=" & rCell.Value & "+aftermarket"
Do While IE.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading Web page”"
DoEvents
Loop
dv = IE.document.getElementsByClassName("_Rnb fmob_pr fac-l")(0).innerText
dd = IE.document.getElementsByClassName("fac-el")(0).innerText
dc = IE.document.getElementsByClassName("vk_gy vk_h _KNe")(0).innerText
rCell.Offset(, 1).Value = dc
rCell.Offset(, 2).Value = dv
rCell.Offset(, 3).Value = dd
Next rCell
Set IE = Nothing
Call IE_Sledgehammer
End Sub
Thanks in advance
Basically, this code runs a search on Google for a stock symbol and returns the aftermarket value along with the company name and market close value.
Everything works as it should but slowly.
Is there a faster method?
Sub WorkingWebScraper() Dim IE As Object, dd As Double, dv As Double, dc As String, rCell As Range
Sheet1.Range("B4:D88,I4:M24,O4:S24").ClearContents
Sheet1.Range("A1").Value = "Laste update: " & Now()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
On Error Resume Next
For Each rCell In Sheet1.Range(Sheet1.Range("A4"), Sheet1.Range("A4").End(xlDown)).Cells
IE.navigate "https://www.google.co.uk/search?q=" & rCell.Value & "+aftermarket"
Do While IE.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading Web page”"
DoEvents
Loop
dv = IE.document.getElementsByClassName("_Rnb fmob_pr fac-l")(0).innerText
dd = IE.document.getElementsByClassName("fac-el")(0).innerText
dc = IE.document.getElementsByClassName("vk_gy vk_h _KNe")(0).innerText
rCell.Offset(, 1).Value = dc
rCell.Offset(, 2).Value = dv
rCell.Offset(, 3).Value = dd
Next rCell
Set IE = Nothing
Call IE_Sledgehammer
End Sub
Thanks in advance