gpt4 book ai didi

javascript - YouTube的jQuery获取视频页面HTML

转载 作者:行者123 更新时间:2023-12-03 06:30:58 24 4
gpt4 key购买 nike

嗨,我只是想简单地从youtube获取一个网址并代表html内容。
我的代码现在看起来像这样:

$.ajax({url: "http://www.youtube.com/watch?v=VIDEOID",
type: 'get',
dataType:'jsonp',
crossDomain:true,
success: function(data,text,xhqr){
console.log(data);
}
});

结果是:
Resource interpreted as Script but transferred with MIME type text/html: "http://www.youtube.com/watch?v=rr5EyyhSU_k&callback=jQuery110209012887296266854_1387530192875&_=1387530192876". jquery.js:8516 Uncaught SyntaxError: Unexpected token < 

而且我没有数据...有人可以帮我吗? :)

最佳答案

试试这个,

    $.ajax({             
url: 'http://query.yahooapis.com/v1/ public/yql',
data: {q: "select * from json where url ='http://www.youtube.com/oembed?url=http:// www.youtube.com/watch? v=wbp-3BJWsU8&format=json'",format: "json" },
dataType: "jsonp",
success: function (data) {
alert(JSON.stringify(data));
},
error: function (result) {
alert("Sorry no data found.");
}
});

关于javascript - YouTube的jQuery获取视频页面HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20699948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com