excel - Access iFrame from vba correctly -
i trying product description field amazon.
for example: http://www.amazon.com/gmc-denali-black-22-5-inch-medium/dp/b00fnvbs5c/ref=sr_1_1?s=outdoor-recreation&ie=utf8&qid=1436768082&sr=1-1&keywords=bicycle
this code:
sub scrapeproductdesc() dim ie new internetexplorer dim weburl dim docx htmldocument dim productdesc dim rcdnum ie.visible = false rcdnum = 2 thisworkbook.worksheets(1).range("a65536").end(xlup).row weburl = thisworkbook.worksheets(1).range("a" & rcdnum) ie.navigate2 weburl until ie.readystate = readystate_complete doevents loop set docx = ie.document producttitle = docx.getelementbyid("producttitle").innertext '####### product desc productdesc = ie.document.window.frames("product-description-iframe").contentwindow.document.getelementsbyclassname("productdescriptionwrapper").innertext 'print workbook thisworkbook.worksheets(1).range("a" & rcdnum) = productdesc next end sub as product description in iframe doing: productdesc = ie.document.window.frames("product-description-iframe").contentwindow.document.getelementsbyclassname("productdescriptionwrapper").innertext
however, error message: object not support property or method. line.
i guess accessing iframe not correct.
any suggestion how access iframe correctly?
try declaring variable as mshtml.htmlwindow2 , setting equal docx.frames(0)
sub scrapeproductdesc() dim ie new internetexplorer dim weburl dim docx htmldocument dim productdesc dim rcdnum dim prdt mshtml.htmlwindow2 ie.visible = false rcdnum = 2 thisworkbook.worksheets(1).range("a65536").end(xlup).row weburl = thisworkbook.worksheets(1).range("a" & rcdnum) ie.navigate2 weburl until ie.readystate = readystate_complete doevents loop set docx = ie.document set prdt = docx.frames(0) producttitle = prdt.document.getelementbyid("producttitle").innertext '####### product desc productdesc = prdt.document.getelementsbyclassname("productdescriptionwrapper")(0).innertext 'print workbook thisworkbook.worksheets(1).range("a" & rcdnum) = productdesc next end sub
Comments
Post a Comment