无法使用Cheerio获取iframe

时间:2017-07-06 05:54:16

标签: javascript html node.js iframe cheerio

您好我正试图从wathfree.to获取iframe。

以下是我为此目的使用的代码:



function getSecondBody(url2)
{
    url2 = 'http://www.watchfree.to/watch-366-Forrest-Gump-movie-online-free-putlocker.html';
    request(url2, function(err, resp, body)
{
	var $  = cheerio.load(body);
    
	var embedcode = $('.links_left_container');
	 embedcodetext2 = embedcode.html();
	console.log(embedcodetext2);
	return embedcodetext2;
});
}




但是返回的回复并不包含我需要的iframe。

这是我收到的回复:

response on console

虽然实际页面如下所示: orignal page

我的回复中只缺少iframe部分。

1 个答案:

答案 0 :(得分:2)

view-source:http://www.watchfree.to/watch-366-Forrest-Gump-movie-online-free-putlocker.html

请查看页面的来源。没有iframe。它的通用内容。因此,当您提出请求时,它不会加载到DOM。

如果你想要openload嵌入链接,你需要抓取这一行:

var locations = ["http:\/\/streamin.to\/embed-k2msgp8yhhd8-580x326.html","http:\/\/streamin.to\/embed-cbp8zxw3yo3f-580x326.html","http:\/\/embed.nowvideo.sx\/embed.php?v=2729070a4365a","http:\/\/thevideo.me\/embed-wm815ejm5uvb-580x326.html","https:\/\/estream.to\/embed-6u49dntawgr0.html","http:\/\/thevideo.me\/embed-n14mh2bjj2nz-580x326.html","http:\/\/vidtodo.com\/embed-bmjw5u1e18js.html","http:\/\/vidtodo.com\/embed-z8614uxy1824.html","https:\/\/openload.co\/embed\/xTLPXjSGz7o\/","https:\/\/openload.co\/embed\/F8gJS5Y1o1o\/"];