Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,064
- Office Version
- 2016
- Platform
- Windows
I need a bit of help on web automation, my whole code only extracts the urls into column A, but I can not workout how to do the others in the remaining columns. appriciate if someone could have a look. I need the bits that are commented out in green in the code
VBA Code:
'<h3 class="s-item__title s-item__title--has-tags">5" Android 8.1 Unlocked Cheap Mobile Smart Phone Quad Core Dual SIM WiFi 3G GPS</h3>
' <div class="s-item__subtitle">2020 NEW YEAR GIFT,1st 50% OFF,UK Stock</div>
'<span class="SECONDARY_INFO">Brand new</span>
'<span class="s-item__price">£31.85<span class="DEFAULT"> to </span>£38.58</span>
'<span class="POSITIVE">FAST & FREE</span>
'<span class="BOLD">Free postage</span>
'<span class="BOLD NEGATIVE">205+ sold</span>
For Each link In HTMLDoc.getElementsByTagName("a")
If link.getAttribute("class") = "vip" Then
Cells(i, 1).Value = link.getAttribute("href")
i = i + 1
End If
Next link
If pageNumber >= 3 Then Exit Do 'the first 3 pages
Set nextPageElement = HTMLDoc.getElementsByClassName("gspr next")(0)
If nextPageElement Is Nothing Then Exit Do
nextPageElement.Click 'next web page
Do While IE.Busy Or IE.readyState <> 4
DoEvents
Loop
Application.Wait Now + TimeSerial(0, 0, 5)
Set HTMLDoc = IE.document
pageNumber = pageNumber + 1
Loop
IE.Quit