Webscraping Grocery Website

JohnDoe1976

New Member
Joined
Nov 17, 2020
Messages
2
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Platform
  1. 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 : (


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:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

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