我正在尝试编写一个小型 javascript 函数,该函数将允许用户提交特定的 youtube 频道 url,然后返回该频道上的观看次数。有人知道吗?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="demo">Click the button to get the value of the attribute with the specified namespaceURI and name</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var http;
if (window.XMLHttpRequest) {xhttp=new XMLHttpRequest();}
else {xhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xhttp.open("GET","booksns.xml",false);
xhttp.send();
var xmlDoc=xhttp.responseXML;
var price=xmlDoc.getElementsByTagName("price")[0];
var x=document.getElementById("demo");
x.innerHTML=price.getAttributeNS("http://www.w3schools.com/NS","currency");
};
</script>
</body>
</html>