我写了一个接收视频的解析器。不能将生成的视频本身保存到我想要的文件夹中。如何修复,这是代码。
foreach ($href as $key => $link) {
$doc = file_get_html('https://example.com/'.$link);
foreach($doc->find("#video source") as $el) {
$video[]="https:".$el->src;
}
}
//finally I get
/* array(
"http:example/video1.mp4",
"http:example/video2.mp4",
"http:example/video3.mp4")
*/
$dirSubtitles=$_SERVER['DOCUMENT_ROOT'].'/video/';
foreach ($video as $key=>$address) {
$url = $address;
$path = $dirSubtitles;
$fp = fopen($path."video".$key, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
}