Google Spreadsheet使用importxml获取文本 [英] Google Spreadsheet getting text with importxml

查看:132
本文介绍了Google Spreadsheet使用importxml获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过此版本和其他版本了吗?有人可以帮忙吗?

I've tried this and other versions to no avail? Can anyone help please?

=IMPORTXML("http://performance.morningstar.com/fund/ratings-risk.action?t=MWTRX", "//*[@id='div_ratings_risk']/table/tbody/tr[4]/td[3]/text()")

推荐答案

如您对原始问题的注释中所述,最初ID为#div_ratings_risk的div元素最初为空,并且不包含表. 因此,Google电子表格无法解析不存在但仍需要首先加载的内容.

As explained in the comments to your original question, initially the div Element with the id #div_ratings_risk is initially empty and does not consist of a table. So Google spreadsheets is not able to parse content that is not there and yet needs to be loaded first.

您尝试从另一个URL使用jQuery动态加载您尝试从中获取数据的内容(表).您可以使用以下网址获取该网址: chrome开发人员工具和针对XHR请求的过滤器.

The content (table) you try to fetch data from into your google spreadsheet is dynamically loaded using jQuery from another URL. You can get that URL using e.g. the chrome developer tools and filter for XHR request.

如果直接从该HTML解析内容,它将起作用.因此,您需要将公式更改为该URL,并像这样修改XPath:

If you parse the content directly from that HTML it will work. So you would need to change your formula to that URL and adapt your XPath like so:

=IMPORTXML("http://performance.morningstar.com/ratrisk/RatingRisk/fund/rating-risk.action?&t=XNAS:MWTRX&region=usa&culture=en-US&cur=&ops=clear&s=0P00001G5L&ep=true&comparisonRemove=null&benchmarkSecId=&benchmarktype=", "//table/tbody/tr[4]/td[3]/text()")

这篇关于Google Spreadsheet使用importxml获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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