1

I have some problem to use importXML function in my spreadsheet. I used function 'importxml' and it was worked! Also, it stacked data well (with GA). But some day, a function error appeared #n/a(error import content is empty). I have no clue why this error happens.

Sample Url: http://www.yes24.com/searchcorner/Search?query=9788998599362 (for reference, it's a Korean website)

Xpath

//p[contains(@class,'goods_rating')]/text()[1]

I change Xpath to '*' and parsing head tag inside text and it's working! I think the web site doesn't block the google spreadsheet function.

But with no reason(or any clue) importxml cannot parse body tag inside text anymore. It just prints #n/a error.

I also checked with Chrome Xpath helper to Xpath Syntax. It could track the text, there seems no problem.

How can I fix this problem?

P.S:red box is Xpath target

enter image description here

Rubén
  • 34,714
  • 9
  • 70
  • 166

1 Answers1

0

Try

=importxml("http://www.yes24.com/searchcorner/Search?query=9788998599362","//*[@id='schMid_wrap']/div[3]/div[2]/table/tr[1]/td[2]/p[4]/text()[1]")

How I got this

When you visit the page,

  • Right-click on the element you want you import, and select Inspect
  • In the Inspect pane, if you do not see the element, open the collapsible arrows on the highlighted section until you see your element.
  • Right-click on the element, Copy, Copy XPath
  • Paste XPath in to the second parameter of the =importxml()
  • There will be double quotes (" ") just after the @id=, you will need to change them to single quotes so the =importxml() includes it into the string.
  • Test it, if it doesn't work, remove /tbody

See: Why do browsers insert tbody element into table elements? to see why /tbody was there in the first place.

Note

I had trouble with this XPath too, I ended up just changing the quotes and deleting the stuff in Bold and it worked for me.

//*[@id="page-wrapper"]/span/div/div[3]/div[1]/div[2]/div[1]/div/div[18]/article/div[4]/div[1]/div[1]/div[1]/span

Rubén
  • 34,714
  • 9
  • 70
  • 166
Stevo
  • 248
  • 4
  • 8