[英]How to IMPORTXML into Google Sheets from site with next-click/load-more pagination
I'm trying to scrape a list of news stories for each story's topic, author, timestamp and headline.我正在尝试为每个故事的主题、作者、时间戳和标题抓取新闻故事列表。 The site lists the 10 most recently published stories on a URL that ends in /all-stories, with the next 10 stories on /all-stories/page/2, the next 10 on /all-stories/page/3, and so on.
该网站列出了 URL 上最近发布的 10 个故事,以 /all-stories 结尾,接下来的 10 个故事在 /all-stories/page/2,接下来的 10 个故事在 /all-stories/page/3,依此类推上。
I have 3 IMPORTXML formulas that are capturing the data I need on the first page:我有 3 个 IMPORTXML 公式在第一页捕获我需要的数据:
=importxml("https://www.example.org/all-stories", "//div[@class='post-item-river__content___2Ae_0']/a")
=IMPORTXML("https://www.example.org/all-stories","//li[@class='post-item-river__wrapper___2c_E- with-image']/div/div")
=IMPORTXML("https://www.example.org/all-stories","//li[@class='post-item-river__wrapper___2c_E- with-image']/div/h3")
How do I replicate this on page/2, page/3 and so on?如何在 page/2、page/3 等上复制它?
I haven't seen any way to do this in Google Sheets -- this kinda-similar story attempt involved adding &=ROW() to the URL in the formula.我在 Google 表格中没有看到任何方法可以做到这一点—— 这个有点相似的故事尝试涉及在公式中将 &=ROW() 添加到 URL 中。 But when I tried that, Sheets interpreted it as part of the URL and rightly returned nothing.
但是当我尝试这样做时,Sheets 将其解释为 URL 的一部分,并且正确地没有返回任何内容。
try a simple array like:尝试一个简单的数组,如:
={IMPORTXML("https://www.sciencenews.org/all-stories", "//div[@class='post-item-river__content___2Ae_0']");
IMPORTXML("https://www.sciencenews.org/all-stories/page/2", "//div[@class='post-item-river__content___2Ae_0']");
IMPORTXML("https://www.sciencenews.org/all-stories/page/3", "//div[@class='post-item-river__content___2Ae_0']")}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.