突然importxml#n/错误导入内容为空出现 [英] Suddenly importxml #n/a error import content is empty appear

查看:86
本文介绍了突然importxml#n/错误导入内容为空出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在电子表格中使用importXML函数时遇到一些问题. 我使用了函数"importxml",它确实起作用了!而且,它很好地堆叠了数据(使用GA). 但是有一天,出现了#n/a函数错误(错误导入内容为空). 我不知道为什么会发生此错误.

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.

示例网址: http://www.yes24.com/searchcorner/Search?query=9788998599362 (仅供参考,这是一个韩国网站)

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]

我将Xpath更改为'*'并解析文本内的 head 标记,并且可以正常工作! 我认为该网站不会阻止Google电子表格功能.

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.

但是没有任何理由(或任何线索),importxml无法再解析文本内的 body 标签.它只会显示#n/a错误.

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

我还使用Chrome Xpath辅助程序检查了Xpath语法.它可以跟踪文本,似乎没有问题.

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

如何解决此问题?

P.S:红色框是Xpath目标

P.S:red box is Xpath target

推荐答案

尝试

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

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]")

当您访问页面时,

  • 右键单击要导入的元素,然后选择检查"
  • 在检查"窗格中,如果看不到元素,请打开突出显示部分上的可折叠箭头,直到看到您的元素为止.
  • 右键单击元素,复制,复制XPath
  • 将XPath粘贴到 = importxml()
  • 的第二个参数中
  • @id = 后将有双引号("),您需要将其更改为单引号,以便 = importxml()包括在内到字符串中.
  • 测试一下,如果它不起作用,请删除"/tbody"
  • 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"

请参阅:为什么浏览器将tbody元素插入表元素? 首先了解为什么"/tbody"在那里.

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

我也遇到了这个XPath的麻烦,我最终只是更改了引号,并删除了 Bold 中的内容,对我来说很有效.

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] /文章/div [4]/div [1]/div [1]/div [1] /span

//*[@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

这篇关于突然importxml#n/错误导入内容为空出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆