Excel VBA Web Scraper to get Amazon Size ASINs from Web Page- Please help!

Hilaryh20

New Member
Joined
Jul 5, 2019
Messages
3
Hello everyone,

I am developing a VBA web scraping tool that will find all of the size variations for an amazon page and get their ASINs (The unique link to each product page.) Any amazon page will do, but here is the web page I used in my example.


https://www.amazon.com/dp/B079M63HK2

The goal here is to create a VBA that will show all of the size ASINs on one excel sheet.

I determined the unique ID to be "size_name_1,size_name_2, size_name_3, size_name_0".


See Web page code below:
"<div id="size_name_1" data-dp-url=/dp/B00JRPQZ1W/ref=twister_B07FNZWKFF?_encoding=UTF8&mp;psc= class="a-section a-spacing-none twisterShelf_swatch">
<div class="a-section a-spacing-none twistershelf_displaysection">

The code follows the same logic in the size_name_2, 3, etc.



I attempted to start the code with just the size_name_1, but I am having some trouble. Can anyone help?

"Private Sub Worksheet_Change ( By Val Target as Range)
If Target.Column=Range("A2:A200").Column Ten
Dim IE as New Internet Explorer
IE.Visible=False
For r=2 to 200
I.E. Navigate https://www.amazaon.com/dp/ &Cells(r,"A").Value
Do while (IE.Busy or IE.ReadyState <>4): DoEvents: Loop

Do
Do Events
Loop Until IE.ReadyState= READYSTATE_COMPLETE
If IsEmpty (Cells(r,"A").Value)= True Then

End

End if

Dim Doc as HTMLDocument
Set Doc =IE.document
Dim Variations as Object
Set Variation= Doc.getElementsbyName("size_name_1")
If Variation.Length = 1 Then
Cells (r,"B")=Doc.GetElementsbyID("size_name_1").GetElementsbyTagName("data")(0)

Else
Cells (r,"B")="NO ASIN SIZE VARIATIONS"
End if
Next r
End if
End Sub"

Thank you in advanced for any assistance!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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