JohnDoe1976
New Member
- Joined
- Nov 17, 2020
- Messages
- 2
- Office Version
- 365
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hi There,
I'm having a lot of trouble trying to get a simple webscrape to work.
I am using a dynamic URL to search for a product (in this case 'GREENE KING ABBOT ALE') and what I'd like to do is have all the available links that return from the site to appear in column A of sheet called 'Single'
This code only intermittently works - it did work once, then it didnt again - i think there are Javascript elements blocking the script from returning ALL urls.
The URL i know is on the page is:
"https://groceries.aldi.co.uk/en-GB/p-greene-king-abbot-ale-500ml/5010549104614"
however I can't get this particular link to copy into my sheet again.
Please can you help - spent all day getting this far and I'm running out of ideas : (
I'm having a lot of trouble trying to get a simple webscrape to work.
I am using a dynamic URL to search for a product (in this case 'GREENE KING ABBOT ALE') and what I'd like to do is have all the available links that return from the site to appear in column A of sheet called 'Single'
This code only intermittently works - it did work once, then it didnt again - i think there are Javascript elements blocking the script from returning ALL urls.
The URL i know is on the page is:
"https://groceries.aldi.co.uk/en-GB/p-greene-king-abbot-ale-500ml/5010549104614"
however I can't get this particular link to copy into my sheet again.
Please can you help - spent all day getting this far and I'm running out of ideas : (
VBA Code:
Sub webscrape()
Sheets("Single").Cells.Clear
Dim doc As HTMLDocument
Dim output As Object
Set IE = CreateObject("InternetExplorer.Application")
'Set IE = New InternetExplorer
IE.Visible = False
IE.Navigate "https://groceries.aldi.co.uk/en-GB/Search?keywords=GREENE+KING+ABBOT+ALE"
Do
DoEvents
Loop Until IE.ReadyState = READYSTATE_COMPLETE
Set doc = IE.Document
Set output = doc.getElementsByTagName("a")
i = 5
For Each Link In output
Sheets("Single").Range("A" & i).Value = Link
i = i + 1
Next
End Sub
Last edited by a moderator: