Hi All,
I have written following piece of code to scrap Quantities available for a product for each colors and return it as a string.
So if the code works as expected following will be the output for URL
Output: Avalon Light Brown: 10+ in Stock, Rich Tobacco Brown: 10+ in Stock
It works very good in IE10, but not in IE11 unfortunately. Can anybody please help me on this?![]()
Sub Call_Func() MsgBox Get_Qty_IAS("http://www.wayfair.com/Simpli-Home-Acadian-Entryway-Bench-QSI1070.html") End Sub Private Function Get_Qty_IAS(URL As String) As String Dim doc 'As HTMLDocument Dim Listings 'As IHTMLElementCollection Dim anchorElement 'As HTMLAnchorElement Dim NoOptions As Boolean Dim OptionsCt As Long, OptNo As Long Dim OptionsStr As String Dim objIE As Object Set objIE = CreateObject("InternetExplorer.Application") objIE.Visible = True objIE.Navigate (URL) bError = False Do DoEvents 'Application.Wait Now + TimeSerial(0, 0, 1) Loop Until objIE.ReadyState = 4 ' getting the HTML document Set doc = objIE.Document 'Check for Options available like color or style NoOptions = True If doc.getElementsByClassName("js-visual-option-block visual_option_block").Length > 0 Then NoOptions = False End If If NoOptions = True Then ' No options are available Set Listings = doc.getElementsByClassName("stock_count textbox") If Listings.Length > 0 Then Get_Qty = Listings.Item(0).InnerText End If Else OptionsStr = "" OptionsCt = doc.getElementsByClassName("js-visual-option-hover visual_option_hover").Length ' Looping through the options For OptNo = 0 To OptionsCt - 1 Set anchorElement = doc.getElementsByClassName("js-visual-option visual_option_wrap pos_rel fl").Item(OptNo) anchorElement.Click If InStr(1, Application.WorksheetFunction.Clean(doc.getElementsByClassName("js-visual-option visual_option_wrap pos_rel fl")(OptNo).InnerText), "add", vbTextCompare) = 0 Then OptionsStr = OptionsStr & Application.WorksheetFunction.Clean(doc.getElementsByClassName("js-visual-option visual_option_wrap pos_rel fl")(OptNo).InnerText) & ": " Else OptionsStr = OptionsStr & Left(Application.WorksheetFunction.Clean(doc.getElementsByClassName("js-visual-option visual_option_wrap pos_rel fl")(OptNo).InnerText), InStr(1, Application.WorksheetFunction.Clean(doc.getElementsByClassName("js-visual-option visual_option_wrap pos_rel fl")(OptNo).InnerText), "add", vbTextCompare) - 1) & ": " End If Set Listings = doc.getElementsByClassName("stock_count textbox") OptionsStr = OptionsStr & Listings.Item(0).InnerText & ", " Next Get_Qty_IAS = Left(OptionsStr, Len(OptionsStr) - 2) End If End Function
Thanks,
Tejas











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks