我正在使用Google电子表格抓取产品价格

时间:2020-04-11 11:07:01

标签: xml xpath web-scraping google-sheets

我要从中提取产品价格的网站的网址为https://www.logsplittersdirect.com/Power-King-PK0342-Log-Splitter/p97062.html

我正在使用Google电子表格的IMPORTXML()方法。但是它什么也没有返回,我也不是为什么。预先谢谢你。

=IMPORTXML("https://www.logsplittersdirect.com/Power-King-PK0342-Log-Splitter/p97062.html","//div[@productsPrice]")

1 个答案:

答案 0 :(得分:1)

网站使用动态渲染(+ geoblock)。这里需要硒。但是我们可以尝试一种变通办法,以在GoogleSheet中获得价值。使用:

=IMPORTXML("https://www.logsplittersdirect.com/Power-King-PK0342-Log-Splitter/p97062.html";"normalize-space(substring-after(substring-before(//script[starts-with(.,'{')],'"",""priceCurrency""'),'""price"":""'))")

输出:

Price