excel vba - Web scraping worked fine in IE 9 but breaks in IE 11 -
i had procedure scraped information website in ie9 after updating ie11 procedure breaks when trying enter piece of data input box on webpage. code recognizes field , listed on object when debug when try enter value box using cusip.value not enter on webpage. think has source being updated after browser updated. have sworn identifier "txtcusipno" in html listed id instead of name. appreciated. thanks.
html website
<td class="tbl1"> <input type="text" name="txtcusipno" value="" class="input" size="11" maxlength="9"> <a href="javascript:;" onclick="window.open('/secfinderii1/sim_seeksearch.jsp?clientobjectreference=frmsearchentry.txtcusipno&formname=frmsearchentry&textboxname=txtcusipno','securityfinder','resizable=yes,scrollbars=yes,status=no');"><img src="/rdpann/pbs/images/lookup.gif" border="0" alt="open security finder" align="absmiddle"></a> <img name="txtcusipimg"src="/rdpann/pbs/images/req.gif" align="absmiddle"> </td> vba code
private sub entercusip() retry: set cusip = doc.getelementbyid("txtcusipno") err.clear vala = activesheet.cells(row, 1) on error resume next cusip.value = activesheet.cells(row, 1) 'insert cusip if err.number = 91 goto retry set currentwindow = ie.document.parentwindow call currentwindow.execscript("javascript:processform(document.forms.frmsearchentry)") 'search (hit enter) if err.number = -2147352319 exit sub on error goto 0 while (ie.busy or ie.readystate <> readystate.readystate_complete):doevents: loop end sub
if suspect html source has been changed , may make unannounced changes in future, recommend switching ie.document.all.item property.
doc.all.item("txtcusipno").value = 123 the .item identifier can either id or name, there no distinction between two. however, concerned identifying factor (e.g. txtcusipno) may not unique on page. yes, supposed growing number of html developers using code divs(0).getelementbyid("txtcusipno") , divs(1).getelementbyid("txtcusipno").
Comments
Post a Comment