Can't click on some dots to scrape information Can't click on some dots to scrape information vba vba

Can't click on some dots to scrape information


No need to click on each dots. Json file has all the details and you can extract as per your requirement.


Installation of JsonConverter

  1. Download the latest release
  2. Import JsonConverter.bas into your project (Open VBA Editor, Alt + F11; File > Import File)Add Dictionary reference/class
  3. For Windows-only, include a reference to "Microsoft Scripting Runtime"
  4. For Windows and Mac, include VBA-Dictionary

References to be added

enter image description here


Download the sample file here.


Code:

Sub HitDotOnAMap()    Const Url As String = "https://www.arcgis.com/sharing/rest/content/items/4712740e6d6747d18cffc6a5fa5988f8/data?f=json"    Dim IE As New InternetExplorer, HTML As HTMLDocument    Dim post As Object, I&    Dim data As String, colObj As Object    With IE        .Visible = True        .navigate Url        While .Busy = True Or .readyState < 4: DoEvents: Wend        data = .document.body.innerHTML        data = Replace(Replace(data, "<pre>", ""), "</pre>", "")    End With    Dim JSON As Object    Set JSON = JsonConverter.ParseJson(data)    Set colObj = JSON("operationalLayers")(1)("featureCollection")("layers")(1)("featureSet")    For Each Item In colObj("features")         For j = 1 To Item("attributes").Count - 1                Debug.Print Item("attributes").Keys()(j), Item("attributes").Items()(j)         Next    NextEnd Sub

Output

enter image description here