0
我正在做的Greasemonkey脚本从YouTube结果提取视频网址代码: 我有这样的:检索页面的源代码在JavaScript
// ==UserScript==
// @name extract
// @namespace here
// @include http://stackoverflow.com/
// @grant GM_xmlhttpRequest
// @version 0.1
// ==/UserScript==
window.setTimeout(conseguir_articulos_youtube, 5000);
function conseguir_articulos_youtube(){
GM_xmlhttpRequest({
method: "GET",
url: "http://www.youtube.com/results?search_sort=video_date_uploaded&uni=3&search_type=videos&search_query=humor",
onload: on_load_extract
});
}
function on_load_extract(data){
var datos=data.responseText;
alert(datos);
}
我使用XMLHttpRequest来检索YouTube上的内容,但是响应中出现的页面代码并不完整。有一种形式可以在javascript中检索页面的完整源代码?
为什么不使用youtube API在JSON中获得结果? – charlietfl
使用API。如果你坚持这样做很难,请参阅[如何在返回响应之前获取AJAX get-request等待页面呈现](http://stackoverflow.com/q/11486256/331508)。 –