我只是在寻找屏幕抓取包含flash视频的网页。在使用PHP Simple HTML DOM Parser抓取网页时,我喜欢抓取嵌入的代码片段并下载视频数据。有人能帮上忙吗?
参考可能的帮助:How to find object tag with param and embed tag inside html using simple html d
发布于 2015-01-19 23:26:25
我不认为有一个通用的解决方案,否则youtube-dl在许多网站上的special-casing就没有必要了。如果你脑海中的站点在这个列表上,我建议你简单地使用youtube-dl。
发布于 2015-01-26 04:38:18
如果你使用的是linux服务器,你可以为youtube-dl使用这个小PHP包装器。只需将包含视频的页面的url传递给函数即可。
function video_download($video_url) {
$downloaderUrl = 'https://yt-dl.org/downloads/2015.01.23.4/youtube-dl';
$downloaderPath = '/tmp/youtube-dl';
$videoPath = '/tmp/videos';
if(!file_exists($videoPath.'/')) {
mkdir($videoPath, 0777);
}
if(!file_exists($downloaderPath)) {
file_put_contents($downloaderPath, file_get_contents($downloaderUrl));
chmod($downloaderPath, 0777);
}
exec($downloaderPath.' -o "'.$videoPath.'/%(title)s.%(ext)s":w '.$video_url);
return true;
}使用示例:
video_download('http://www.youtube.com/watch?v=9bZkp7q19f0');如果你对一些解释感兴趣,只需从网站上获取youtube-dl下载程序,将其保存到你的临时文件夹中,然后使用传递的url运行它。结果将保存到tmp中的其他文件夹中。
https://stackoverflow.com/questions/28027921
复制相似问题