Google Spreadsheet getting text with importxml

自古美人都是妖i 提交于 2020-01-14 14:16:28

问题


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

回答1:


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.

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.

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


来源:https://stackoverflow.com/questions/47383502/google-spreadsheet-getting-text-with-importxml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!