首页 > 解决方案 > 嵌入指向最新 YouTube 视频的链接

问题描述

我正在寻找一个代码,它将嵌入到我最近的 YouTube 视频的超链接。像这样的东西 - https://latestyoutu.be/

我使用下面的代码来嵌入最新视频的 iframe,但我正在努力将其转换为文本超链接。我还需要它链接到 YouTube 上的实际页面,而不是嵌入的 iframe。

谢谢

<script id="youtubeLatest" style="color: red;">
(async function channelID (channelID) {
  const reqURL = "https://api.rss2json.com/v1/api.json?rss_url=" + encodeURIComponent("https://www.youtube.com/feeds/videos.xml?channel_id=") + channelID;
  const repl = await fetch(reqURL).then(r => r.json());
  const url = repl.items[0].link;
  document.write(`<a href="${url}" target="_blank">Latest Upload</a>`);
})("UCWzZ5TIGoZ6o-KtbGCyhnhg");
</script>

标签: javascripthtmliframeyoutube

解决方案


推荐阅读