简体   繁体   English

如何通过单击/加载更多分页从站点将 XML 导入 Google 表格

[英]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.

相关问题 如何在 Google 表格中的 importxml 公式中定义范围 - How to define range in importxml formula in Google Sheets ImportXML Xpath Google 表格 - ImportXML Xpath Google Sheets 如何将= importxml结果放入Google脚本数组? - how to place =importxml result to a google script array? 谷歌表格从列中查找下一个数值 - Google sheets Find next numeric value from the colnums 使用 IMPORTXML 使用 Google 表格对纽约州账单进行网络抓取共同赞助商 - Web Scraping Co-Sponsors on NYS Bills using Google Sheets using IMPORTXML Arrayformula 用于在 Google 表格中查找条件的下一个值 - Arrayformula to find next value for criteria in Google Sheets 如何使用 Google 表格应用程序脚本将 JSON 中的多个 arrays 添加到 Google 表格中 - How to add multiple arrays from JSON into Google Sheets using Google Sheets app script 如何使用谷歌应用脚本将数组写入工作表列并将自定义公式添加到旁边的列? - How to write array to sheets column and add custom formula to column next to it using google apps script? 使用JavaScript / jQuery从数组填充列表并在“加载更多”按钮单击时加载更多项目? - Using JavaScript/jQuery to populate the list from an array and loading more items on 'load more' button click? 如何从数组加载数据列表中的更多数据 - How to load more data in datalist from array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM