Can't get the data using importXML from Dynamic Web Page?

时光毁灭记忆、已成空白 提交于 2020-01-21 09:52:07

问题


The website is : https://www.futbin.com/18/player/2600/Ayhan/

I inspect the element and get the XPath which is: //*[@id="ps-lowest-1"]

Then I use:

=IMPORTXML("https://www.futbin.com/18/player/2600/Ayhan/","//*[@id='ps-lowest-1']")

To get the data which should be 2000

But instead it only shows: - on the sheet. No errors just doesn't show the data that I want it to. Is there anyway to get the data that I need?

Thanks


回答1:


The Sheets command importXML reads only the HTML source of the page without executing any JavaScript on it. As you can see yourself by using "view source" in the browser, the source indeed has "-" in that span:

 <span class="price_big_right">
     <span id="ps-lowest-1">-</span>
 </span>

The actual numbers are loaded by some JavaScript file which then inserts them in that span. Neither importXML nor other Sheets functions can retrieve dynamically inserted data.

Sometimes, after inspecting the JS files, one can uncover the URL of source of data and try to import that; but this is a tedious reverse engineering exercise for each particular site.



来源:https://stackoverflow.com/questions/46747757/cant-get-the-data-using-importxml-from-dynamic-web-page

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