google 个工作表上的 IMPORTxml

IMPORTxml on google sheets

尝试在 google sheet 上传播sheet 从站点抓取数据。

我正在尝试从 rsbuddy exchange 获取商品的售价,例如:

https://rsbuddy.com/exchange/?id=1745

我在 google sheets 上有代码:

=IMPORTxml("https://rsbuddy.com/exchange/?id=1745","//*[@id='sell-price']")

但我没有看到 1734gp,它在 sheet 上显示为 ---。 我试过在 importxml 的查询末尾添加 /text() 但它没有改变任何东西。

我猜解决方案与此类似?

我不相信你可以用 xpath 做到这一点,因为它是动态填充的。如果您查看完整的源代码,您就会得到其中的内容。字面意思是---

可以看到源数据here which is in JSON and looks like it's tied to the page url id. Google sheets doesn't natively support json but this good person wrote a script and it seems to work well in my example sheet

您需要通过 JSON 完成此操作,但您无法通过 Google 表格本地导入JSON。如果您将此库作为代码添加到您的 sheet(通过脚本编辑器),那么您可以使用 =IMPORTJSON(使用不同的参数)来取回您需要的数据。

http://blog.fastfedora.com/projects/import-json