Do you know if the data can be exported as JSON files?
It only seems to mention XML
'---------------------------------------------------------------------------------------
' Procedure : AsinSoldByAmazon
' Author : mellon
' Date : 27-Oct-2017
' Purpose :To see if an ASIN (amazon talk for a vendor product??) is Dispatched and Sold By Amazon
'
'This function returns:
' True if product sold by amazon
' False if product not sold by amazon
'---------------------------------------------------------------------------------------
'
Public Function AsinSoldByAmazon(ReqASIN As String) As Boolean 'ReqASIN As String
'Public Function GetElementById()
Dim tempINfo As String
Dim BaseURL As String
'Dim ReqASIN As String
10 On Error GoTo AsinSoldByAmazon_Error
'ReqASIN = "B001KOTNG2"
20 BaseURL = "https://www.amazon.co.uk/dp/"
Dim id As String
Dim SoldByAmazon As Boolean
Dim XMLHTTP As Object, html As Object, objResult As Object
30 Set XMLHTTP = CreateObject("MSXML2.serverXMLHTTP")
40 XMLHTTP.Open "GET", BaseURL & ReqASIN, False
50 XMLHTTP.setRequestHeader "Content-Type", "text/xml"
60 XMLHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0"
70 id = "merchant-info"
80 XMLHTTP.send
90 DoEvents
100 Set html = CreateObject("htmlfile")
110 html.body.innerHTML = XMLHTTP.responseText
120 Set objResult = html.GetElementById(id)
130 tempINfo = objResult.innerHTML
140 tempINfo = Mid(tempINfo, 20, 60) '29,6) ''JED adjusted based on trial and error with "B0009VX1ZG"
150 'Debug.Print tempINfo
160 If tempINfo Like "*Amazon*" Then
170 AsinSoldByAmazon = True
180 Else
190 AsinSoldByAmazon = False
200 End If
GetElementById_Exit:
210 Exit Function
AsinSoldByAmazon_Exit:
220 Exit Function
AsinSoldByAmazon_Error:
230 MsgBox "Error " & Err.Number & " in line " & Erl & " (" & Err.Description & ") in procedure AsinSoldByAmazon of Module ModJdraw"
240 Resume AsinSoldByAmazon_Exit
End Function
Sub testAmazon()
'FROM Pesky
'B0073H1CIC False
'B00UQ8D5OE False
'B01LWQBKMO True
'B0001IW8TW True
'B0009VX1ZG True
10 Debug.Print "started: " & Now
Dim j As Integer
Dim asin(5) As String
20 asin(0) = "B0073H1CIC"
30 asin(1) = "B00UQ8D5OE"
40 asin(2) = "B01LWQBKMO"
50 asin(3) = "B0001IW8TW"
60 asin(4) = "B0009VX1ZG"
70 asin(5) = "B00CEVFMTW" 'I added this one
80 For j = LBound(asin) To UBound(asin) Step 1
90 Debug.Print "j:" & j & " " & asin(j) & " sold by amazon Is " & AsinSoldByAmazon(asin(j))
100 Next j
110 Debug.Print "Ended: " & Now
End Sub
started: 27-Oct-2017 5:28:10 PM
j:0 B0073H1CIC sold by amazon Is False
j:1 B00UQ8D5OE sold by amazon Is False
j:2 B01LWQBKMO sold by amazon Is True
j:3 B0001IW8TW sold by amazon Is True
j:4 B0009VX1ZG sold by amazon Is True
j:5 B00CEVFMTW sold by amazon Is False
Ended: 27-Oct-2017 5:28:31 PM
Note: I found an issue with the original test when using ASIN B0009VX1ZG. The original check to see that Mid(xxx,29,6) did not match "amazon". The html was different. So I modified the lenght and changed from = to Like.
I also did the same on my version - if you look at the screenshot for records 3 & 4 the output was Amazon followed by a full stop.
So I also used like *Amazon* to check if it was true.
Oddly record 5, B0009VX1ZG, just gave Amazon so I didn't need the wildcard for that one
Temp = objResult.innerHTML
If InStr(1, Temp, "Amazon")>0 Then
SoldBy = "Amazon"
Else
SoldBy = "Other"
End If
Looking at line 60 in the function, does the code still work if using another browser instead of Firefox e.g. Chrome or Edge?
130 tempINfo = objResult.innerHTML
[COLOR="Blue"]140 tempINfo = Mid(tempINfo, 1, 80) '29,6) ''JED adjusted based on trial and error with "B0009VX1ZG"
150 ' Debug.Print tempINfo
160 If tempINfo Like "*Dispatched from and sold by Amazon*" [/COLOR]Then
170 AsinSoldByAmazon = True
180 Else
190 AsinSoldByAmazon = False
200 End If
....
130 tempINfo = objResult.innerHTML
Debug.Print tempINfo
....
started: 27-Oct-2017 10:18:12 PM
Dispatched from and sold by <A href="about:/gp/help/seller/at-a-glance.html/ref=dp_merchant_link?ie=UTF8&seller=A1KDCT42GCX3ZR">neatsales</A>. <SPAN></SPAN>
j:0 B0073H1CIC sold by amazon Is False
Dispatched from and sold by <A href="about:/gp/help/seller/at-a-glance.html/ref=dp_merchant_link?ie=UTF8&seller=A7YZ1S6Z0TLZ3">Langley Steelworks Ltd</A>. <SPAN></SPAN>
j:1 B00UQ8D5OE sold by amazon Is False
Dispatched from and sold by Amazon. <SPAN>Gift-wrap available. </SPAN>
j:2 B01LWQBKMO sold by amazon Is True
Dispatched from and sold by Amazon. <SPAN>Gift-wrap available. </SPAN>
j:3 B0001IW8TW sold by amazon Is True
<SPAN id=pe-text-availability-merchant-info>Dispatched from and sold by Amazon <B>exclusively for Prime members</B>. </SPAN><SPAN id=pe-bb-details-trigger class=a-declarative data-action="a-popover" data-a-popover='{"name":"primeExclusiveIntro","activate":"onclick","width":"450","header":"Exclusively for Amazon Prime Members","position":"triggerHorizontal"}'><A id=pe-link-availability-details class="a-link-normal prime-exclusive-details-link-trigger a-text-normal" href="about:blank#">Details </A></SPAN><BR><SPAN>Gift-wrap available. </SPAN>
j:4 B0009VX1ZG sold by amazon Is True
Dispatched from and sold by <A href="about:/gp/help/seller/at-a-glance.html/ref=dp_merchant_link?ie=UTF8&seller=A22A10WS32DZ1V">go4products</A>. <SPAN></SPAN>
j:5 B00CEVFMTW sold by amazon Is False
Ended: 27-Oct-2017 10:18:33 PM
Pesky,
My guess is that Amazon, like Google and others, may have some restrictions to prevent tying up their servers. Google maps will let a "free account" access approximately 2000 urls per day. I have had interaction with posters suggesting breaking up a number of requests to < 2000/day so google doesn't block your account/ip addr or whatever.
If Count < 80 Then
XMLHTTP.setProxy 2, "http=178.62.28.110:8118"
Else
XMLHTTP.setProxy 2, "http=139.59.175.229:8118"
End If