I've developed a macro that scrapes the amazon website to know whether or not an ebook is part of their Kindle Unlimited program based on an ID. Given there are several different marketplaces (.com, .de, .fr etc...), I created a dropdown menu to choose the marketplace you want to check on. Based on these elements, it creates a concatenated link that it scrapes for a certain HTML element. Here's an example of a link: http://www.amazon.com/dp/B00F3I7N3Q
Here's the code:
[/SIZE]Sub KU_Availability()Application.ScreenUpdating = FalseSet IE = New InternetExplorerMediumIE.Visible = FalseDim i As IntegerLastRow = Range("A" & Rows.Count).End(xlUp).RowFor i = 3 To LastRow IE.navigate "http://www.amazon" & Application.Workbooks("KU Availability hunter").Worksheets("sheet1").Range("B1").Value & "/dp/" & Worksheets("sheet1").Cells(i, 1).Value DoDoEventsLoop Until IE.readyState = READYSTATE_COMPLETEDim doc As HTMLDocumentSet doc = IE.documentOn Error Resume NextIf Application.Workbooks("KU Availability hunter").Worksheets("sheet1").Cells(1, 2).Value = ".fr" ThenApplication.Workbooks("KU Availability hunter").Worksheets("sheet1").Cells(i, 2).Value = Trim(doc.getElementById("KU_logo"))ElseApplication.Workbooks("KU Availability hunter").Worksheets("sheet1").Cells(i, 2).Value = Trim(doc.getElementById("kuBadge")) End If Next i IE.QuitMsgBox ("Finished.")Columns("B:B").SelectSelection.Replace What:="[object HTMLImageElement]", Replacement:="Yes", _ LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _ False, ReplaceFormat:=FalseApplication.ScreenUpdating = TrueEnd Sub[size=14]
The thing I find extra odd is that this runs perfectly when I choose marketplaces .com, .co.uk, .de and .fr.
However, trying with these: .ca, .es, .it, .cn, .com.br, .com.mx, .com.au, .in, .nl
Two Things happen:
1. IE opens to the correct page it's supposed to scrape despite "IE.Visible = False". This doesn't happen with the working marketplaces.
2. I get the error in title.
I've looked at all the articles on Stackoverflow I could find on the matter and can't seem to find a definite answer. I did find a MS page (https://support.microsoft.com/en-us/kb/319832) that encourages the use of "Option Explicit" but I tried and got the same results. Any ideas?
Thank you all.