javascript - 嵌入指向最新 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>
解决方案
推荐阅读
- hibernate - 为什么 Quarkus-Hibernate 在我们已经给出 @DataSource 的情况下还要寻找 Persistance.xml?
- angular - 如何在 TypeScript 中使用“as”语法
- wordpress - 来自 wordpress REST API 的身份验证
- python - 使用密码学在 Python 中进行密码解密
- c# - 矩阵乘法:向量到矩阵的转换
- spring-boot - 从Springboot服务器下载名称包含双引号(“)的文件时文件名错误
- jakarta-ee - 将 @RequestScoped Bean 注入 Runnable 类
- angular - Azure DevOps - Angular 项目构建失败并出现错误:Npm 失败并返回代码:3
- java - 在什么情况下 eventloop.inEventLoop() == false?
- python - 将 Kivy Widget 传递给另一个类