shahin
Active Member
I've written a macro using IE to scrape three fields from each container out of a webpage. They all are rightly coming through. However, the problem with the results is that it contains duplicate values. Few days back, with the help of sir chihiro I could write one using dictionary which can handle duplicates on the fly when I parse two fields. Now, I've added one more fields within my scraper but can't get any idea to add it to the existing dictionary so that I can scrape three fields kicking out the duplicates. Thanks in advance.
Here is the script:
Here is the script:
Code:
Sub GetItems()
Const URL As String = "https://www.inc.com/profile/sumup-payments-limited"
Dim post As Object, container As Object, idic As Object, key As Variant
Dim a$, b$, c$, R&
Set idic = CreateObject("Scripting.Dictionary")
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate URL
While .Busy = True Or .readyState < 4: DoEvents: Wend
For Each post In .document.getElementsByClassName("profile")
With post.getElementsByTagName("h1")
If .Length Then
a = .item(0).innerText
End If
End With
With post.getElementsByClassName("ifi_industry")(0).getElementsByTagName("dd")
If .Length Then
b = .item(0).innerText
End If
End With
With post.getElementsByClassName("employees")(0).getElementsByTagName("dd")
If .Length Then
c = .item(0).innerText ''how to add this "c" to the existing dictionary like I did in the following line
End If
End With
idic(a) = b ''adding to the dictionary
Next post
For Each key In idic.Keys
R = R + 1: Cells(R, 1) = key
Cells(R, 2) = idic(key)
Next key
.Quit
End With
End Sub