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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Hilaryh20

New Member
Joined
Jul 5, 2019
Messages
3
----Making a few corrections as some information did not go through----


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_2" Data-dp-url= "/dp/b07mC1C1CRN6/ref=twister_B0FNZWKFF" 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 Then
Dim IE as New Internet Explorer
IE.Visible=False
For r=2 to 200
I.E. Navigate https://www.amazon.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!
 

Forum statistics

Threads
1,144,159
Messages
5,722,833
Members
422,460
Latest member
VBA_Noob01

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
Top