vba Code
"Private Sub CommandButton2_Click()
UserForm1.WebBrowser1.Silent = True
Dim Strhtml As String
Dim cntr, a As Integer
cntr = 0
j = 2
a = WorksheetFunction.CountA(Sheet1.Range("A:A"))
UserForm1.TextBox2.Value = a - 1
UserForm1.WebBrowser1.navigate "http://www.amazon.com"
delay 5
While UserForm1.WebBrowser1.readyState = READYSTATE_LOADING
delay 4
Wend
'Do
'j = 2
'On Error Resume Next
While Sheet1.Range("A" & j) <> ""
UserForm1.TextBox1.Value = j
UserForm1.WebBrowser1.navigate "http://www.amazon.com"
delay 5
While UserForm1.WebBrowser1.readyState = READYSTATE_LOADING
delay 4
Wend
Product_Name = Sheet1.Range("A" & j)
Web_Product_Name1 = Sheet1.Range("B" & j)
UserForm1.WebBrowser1.document.getElementById("twotabsearchtextbox").Value = Product_Name
On Error GoTo n
UserForm1.WebBrowser1.document.forms(0).submit
UserForm1.WebBrowser1.document.getElementById("navGoButton").Click
'UserForm1.WebBrowser1.document.getElementById("btnSearch").Click
delay 5
While UserForm1.WebBrowser1.readyState = READYSTATE_LOADING
delay 4
Wend
'UserForm1.WebBrowser1.document.getElementById("search_header").Clicked
Strhtml = UserForm1.WebBrowser1.document.DocumentElement.innerHTML
If InStr(1, Strhtml, "We can't find anything that matches your request") Then
GoTo n
Else
'bunch = GetText1(Strhtml, "productTitle", "</div>")
'bunch = GetText1(Strhtml, "companySearchResults", "</tr>")
'While InStr(1, bunch, "</TR>")
'bunch1 = GetText2(bunch, "<TR", "</TR>")
'comp_nm = GetText2(bunch, "=all>", "</a>")
'Sheet1.Range("B" & j).value = Web_Product_Name1
'bunch1 = GetText2(bunch, "<title", "</title>")
'comp_link = GetText2(bunch1, "Href=", "nodeIndex")
Strhtml = UserForm1.WebBrowser1.document.DocumentElement.innerHTML
bunch = GetText2(Strhtml, "=hl-duplicate-faceout>", "</a>")
bunch1 = GetText2(Strhtml, "=hl-duplicate-faceout>", "</a>")
ActiveCell.Offset(0, 1).Value = bunch1
ActiveCell.Offset(0, 4).Value = bunch
bunch2 = GetText2(Strhtml, "border=0><BR clear=all>", "</a")
ActiveCell.Offset(0, 2).Value = bunch2
bunch3 = GetText2(Strhtml, "=newPrice>", "</div>")
bunch4 = GetText2(bunch3, "<span>", "</span>")
ActiveCell.Offset(0, 3).Value = bunch4
ActiveCell.Offset(1, 0).Select
n:
j = j + 1
End If
cntr = cntr + 1
If cntr = 100 Then
ThisWorkbook.Save
delay 5
cntr = 1
End If
Wend
Exit Sub
End Sub
"
links i want to copy from source
<a href="
wwwdotamazondotcom/AME-Sleepwear-Boys-Roddin-Pajama/dp/B0041ORYRS/ref=lh_di_t_dup
_" title="AME Sleepwear Boys 2-7 Hot Roddin' Coat Pajama, Navy, 3T"
class="hlb-item-link hlb-asin-B0041ORYRS">
<img src="
http://ecx.images-amazon.com/images/I/51B4A6XZYdL._SL500_SS40_.jpg"
width="40" alt="" class="hlb-product-image" height="40" border="0" />
<span class="hlb-item-title">
AME Sleepwear Boys 2-7 Hot Roddin' Coat Pajama, Navy, 3T</span>
My Excel has only product information which get copied into the search box and then after clicking on go button i want to copy the url.
which has the product Code.
</pre>