xpath 提取 YouTube 视频名称?

xpath extract YouTube video name?

如何使用 Google 工作表 =IMPORTXML() 函数从以下 h1 标签中提取数据?

HTML 标签:

<h1 class="title style-scope ytd-video-primary-info-renderer"><yt-formatted-string force-default-style="" class="style-scope ytd-video-primary-info-renderer">XPath query, IMPORTXML &amp; Google Sheets - Advanced Tutorial</yt-formatted-string></h1>

结果:

XPath query, IMPORTXML & Google Sheets - Advanced Tutorial

语法很简单,首先是 xml 的 url,然后是 xpath。小心使用单引号和双引号。

=IMPORTXML("link to your xml file or webpage";"//h1")

或者更具体地说:

=IMPORTXML("link to your xml file or webpage";"//h1[@class='title style-scope ytd-video-primary-info-renderer']")

编辑:并获得您需要的东西:

=IMPORTXML("https://www.youtube.com/watch?v=pwZ44kAeiOo";"//span[@class='watch-title']")

尝试:

=IMPORTXML("https://www.youtube.com/watch?v=MkgR0SxmMKo","//*[@id='eow-title']")

更多@: