nadavb
nadavb

Reputation: 128

Parsing using XML for Google Sheets

Trying to scrape a specific price for google sheets. The element is

<div class="col-sm-6 col-xs-6 text-center bg-grey2 brd_rht pad_none" id="id11">102.4</div>

while the xpath is

//*[@id="id11"]

By using

 =IMPORTXML("http://www.funder.co.il/fund.aspx?id=5122973","//*[@id="id11"]")

I get an #ERROR! sign. I'm quite new to using xpath, so would be glad to know what is wrong with what I did, and how is it possible to get the number 102.4 into google sheets.

Upvotes: 0

Views: 77

Answers (1)

Diego
Diego

Reputation: 9571

You're getting #ERROR! because of the " around id11; they conflict with the quotes being used in the formula. Instead use single quotes ' around id11.

Your xpath selector should be //div[@id='id11']/text(). You can test here.

NOTE: Even with those changes, this won't work. If you visit the source of the link you're trying to pull data from and search for id11, you'll see that there is no value.

<div class="col-sm-6 col-xs-6 text-center bg-grey2 brd_rht pad_none" id="id11"></div>

This is because the data is added via jQuery when you load the page on your browser, so you won't be able to access it using IMPORTXML(). If you can figure out where that data might be coming from originally, you might be able to try this approach with that new source.

Upvotes: 1

Related Questions