Google 表格中的 YouTube 导入数据 (IMPORTXML fnc) 已停止工作

YouTube imported data in Google Sheets (IMPORTXML fnc) has stopped working

我想通过 Google 文档中的 IMPORTXML 函数从 YouTube 获取数据。

以前可以,但现在“导入的内容是空的”。

例如,为了获得喜欢,我使用查询:

=IF(ISNA(IMPORTXML("https://www.youtube.com/watch?v=MkgR0SxmMKo","(//*[contains(@class,'like-button-renderer-like-button')])[1]"))=TRUE,0,
     IMPORTXML("https://www.youtube.com/watch?v=MkgR0SxmMKo","(//*[contains(@class,'like-button-renderer-like-button')])[1]"))

但是现在不能用了,导入的内容是空的。

所以,问题是,应该使用什么查询来获取数据。

您上面的代码正在抓取 YouTube 网站,依赖于 YouTube API 的未记录的功能。

而不是与DTOS -- e.g. paragraphs D.7 and E.6 --, I would suggest you to use the YouTube Data API's endpoint Videos.list, for obtaining the number of likes of any given video through the property statistics.likeCount相矛盾。


以下是 DTOS 关于未记录的功能和抓取的内容:

[D.7] Undocumented Services

You must not use undocumented APIs without express permission. You must access data from YouTube API services only according to the means stipulated in the authorized documentation of that YouTube API service.

You must not reverse engineer undocumented YouTube API services or otherwise attempt to derive the underlying source code of these API services.

[E.6] Scraping

You and your API Clients must not, and must not encourage, enable, or require others to, directly or indirectly, scrape YouTube Applications or Google Applications, or obtain scraped YouTube data or content. Public search engines may scrape data only in accordance with YouTube's robots.txt file or with YouTube's prior written permission.