【问题标题】:Unable to get iframe using Cheerio无法使用 Cheerio 获取 iframe
【发布时间】:2023-03-03 13:59:02
【问题描述】:

您好,我正在尝试从 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。

这是我收到的回复:

而实际页面看起来像这样:

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

【问题讨论】:

  • 你想从这个 html 代码中得到什么?视频链接? iframe 已通过 javascript 附加到 DOM,您可以通过查看页面源 (Ctrl + U for chrome) 看到所有 html,cheerio 可以抓取的内容并转到第 72 行或使用关键字#player_frame 查找,您将看到它是如何工作的.

标签: javascript html node.js iframe cheerio


【解决方案1】:

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\/"];

【讨论】:

  • 你能指定这一行的位置吗?
  • @NaveedKhan 51.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-27
  • 1970-01-01
  • 2015-04-10
  • 1970-01-01
  • 1970-01-01
  • 2016-04-20
相关资源
最近更新 更多