Need Help Scrapping

Joined
Nov 26, 2019
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys,

I need some help here.

What should be my formula if i want to scrappe school ratings from greatschools.org???

Need to scrappe the assigned school ratings (1st three) - Look up value will be Address, City, Zip Code (1 cell each value).

Thanks in advance if ever I get an answer!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
This is the first part, viewing the table:

VBA Code:
Sub Scrape2()
Dim Browser As InternetExplorer, Document As HTMLDocument, elems, doc, i%
Set Browser = New InternetExplorer
Browser.Visible = True
'Browser.Navigate "https://www.greatschools.org/florida/orlando/schools/"
Browser.Navigate "https://www.greatschools.org/" & [a1] & "/" & [b1] & "/schools/"
Do While Browser.Busy And Not Browser.readyState = READYSTATE_COMPLETE
    DoEvents
Loop
Set doc = Browser.Document
Application.Wait (Now + TimeValue("0:00:01"))
Set elems = doc.getElementsByTagName("button")
For i = 0 To elems.Length - 1
    If Len(elems(i).ClassName) = 0 Then elems(i).Click  ' table view
Next
End Sub
 
Upvote 0
This one should do it:

VBA Code:
Sub Scrape2()
Dim Browser As InternetExplorer, Document As HTMLDocument, elems, doc, i%, _
schools As New Collection, ws As Worksheet, res$, c%, url$, lr%, r As Range
Set Browser = New InternetExplorer
Browser.Visible = True
'Browser.Navigate "https://www.greatschools.org/florida/orlando/schools/"
Browser.Navigate "https://www.greatschools.org/" & [a1] & "/" & [b1] & "/schools/"
Do While Browser.Busy And Not Browser.readyState = READYSTATE_COMPLETE
    DoEvents
Loop
Set doc = Browser.Document
Application.Wait (Now + TimeValue("0:00:01"))
Set elems = doc.getElementsByTagName("button")
For i = 0 To elems.Length - 1
    If Len(elems(i).ClassName) = 0 Then elems(i).Click  ' table view
Next
Browser.ExecWB 17, 0
Browser.ExecWB 12, 2
Set ws = Sheets("List1")
ws.Cells.ClearContents
ws.PasteSpecial "HTML", False, False
res = ""
lr = Split(ws.UsedRange.Address, "$")(4)
ws.Activate
Set r = Cells.Find("Showing 1 to 25", [a1], xlValues, xlPart)   ' where data begins
c = 0
i = r.Row + 1
On Error Resume Next
Do While c < 4 And i < lr And schools.Count < 4
    url = GetURL(Cells(i, r.Column))
    If url <> "no" And Not url Like "*success*" And Not url Like "*campaign*" _
    And Not url Like "*How-we-fund*" Then
        schools.Add url, url                ' avoid duplicates
        c = c + 1
    End If
    i = i + 1
Loop
On Error GoTo 0
For i = 1 To schools.Count
    res = res & schools(i) & vbLf
Next
MsgBox res, 64, "Top Three"
End Sub

Function GetURL$(c As Range)
If (c.Range("A1").Hyperlinks.Count <> 1) Then
    GetURL = "no"
Else
    GetURL = c.Range("a1").Hyperlinks(1).Address
End If
End Function
'***************
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top