javascript - Grab data from webpage excel vba with multiple innertext -


i trying grab data webpage , partialy successful. html , javascript knowledge not @ best. can grab data , populate in sheet, want seperate data more if possible.

here's code:

sub get_data_2() 'source code is: 'http://stackoverflow.com/questions/26613043/get-data-out-of-a-webpage-with-vba  dim sht worksheet dim sku string dim rowcount long  set sht = sheet8 set ie = createobject("internetexplorer.application")  rowcount = 1 'this gives columns titel row numer 1. sht.range("a" & rowcount) = "sku"  sht.range("b" & rowcount) = "own titel" sht.range("c" & rowcount) = "emo titel" sht.range("d" & rowcount) = "product info" sht.range("e" & rowcount) = "weight" sht.range("f" & rowcount) = "volum" sht.range("g" & rowcount) = "ean" sht.range("h" & rowcount) = "originalnumber" sht.range("i" & rowcount) = "price" sht.range("j" & rowcount) = "stock" sht.range("k" & rowcount) = "units"       rowcount = rowcount + 1     sku = sht.range("a" & rowcount).value ' **sku 491215 in example**     ie         .visible = false         .navigate "https://www.emo.no/web/eportal/ctrl?action=showiteminfo&itemno=" & sku          while .busy or _             .readystate <> 4             doevents         loop      sht.range("c" & rowcount).value = .document.getelementbyid("itemdetail_heading").innertext     sht.range("d" & rowcount).value = .document.getelementbyid("itemdetail_textbox").innertext     sht.range("e" & rowcount).value = .document.getelementbyid("itemdetail_technicaldatabox").innertext      sht.range("j" & rowcount).value = .document.getelementbyid("itemdetail_deliverybox").innertext     sht.range("k" & rowcount).value = .document.getelementbyid("itemdetail_unitsbox").innertext      end loop while sht.range("a" & rowcount + 1).value <> "" set ie = nothing  end sub 

now, on webpage html source (an extract) follows:

<div id="itemdetail_container"> <div id="itemdetail_heading"> <div class="xxlarge extrabold">papir ubleket kraft 60g 40cm 5kg/rull</div> <div class="item_itemnumberbox"> <span class="darkgray medium">varenr : 491215</span> </div> </div> 

i want text " papir ubleket kraft 60g 40cm 5kg/rull " appear in excel sheet, "varenr : 491215" well. same goes other colums. tried post apicture of thge excel grab, not alowed to. can run code , see, or can e-mail screenshot.

what can data different columns?

many help! :-)

for "papir ubleket kraft 60g 40cm 5kg/rull" change this

.document.getelementbyid("itemdetail_heading").innertext 

to:

.document.getelementbyid("itemdetail_heading").getelementsbytagname("div")(0).innertext 

or (less specific):

.document.getelementbyid("itemdetail_heading").firstchild.innertext 

to "varenr : 491215" -

.document.getelementbyid("itemdetail_heading").getelementsbytagname("span")(0).innertext 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -