【发布时间】:2018-10-03 10:25:17
【问题描述】:
我在 Google 表格上使用 =IMPORTXML 函数并尝试获取#bepartoflegacy 的总帖子数。这是链接https://www.instagram.com/explore/tags/bepartoflegacy/
获取此标签的帖子总数的正确 xPath 表达式是什么?
【问题讨论】:
标签: xpath google-sheets instagram
我在 Google 表格上使用 =IMPORTXML 函数并尝试获取#bepartoflegacy 的总帖子数。这是链接https://www.instagram.com/explore/tags/bepartoflegacy/
获取此标签的帖子总数的正确 xPath 表达式是什么?
【问题讨论】:
标签: xpath google-sheets instagram
您尝试读取的页面看起来包含动态 html。这样做的问题是IMPORTXML函数只读取原始页面源而不执行javascript,这是负责创建img标签的部分:
Can't get the data using importXML from Dynamic Web Page?
但是,在这种情况下,我设法在原始源代码中找到了以下 html 标记:
<meta content="329 Posts - See Instagram photos and videos from ‘bepartoflegacy’ hashtag" name="description" />
所以你可以使用下面的函数调用:
=IMPORTXML("https://www.instagram.com/explore/tags/bepartoflegacy/", "//meta[@name='description']/@content")
【讨论】: