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∓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!
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∓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!