用php写一个获取本地sptxt文件里的mp4视频下载到本地服务器根目录从第一行开始下载下载到2600行结束视频名字是9位随机数
$end_line) {
break;
}
$line = trim($line);
$url = $line;
$ch = curl_init($url);
$fp = fopen($output_dir . "/" . generateRandomString(9) . ".mp4", "wb");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
fclose($file);
function generateRandomString($length = 9) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$characters_length = strlen($characters);
$random_string = '';
for ($i = 0; $i < $length; $i++) {
$random_string .= $characters[rand(0, $characters_length - 1)];
}
return $random_string;
}
?
原文地址: https://www.cveoy.top/t/topic/clxT 著作权归作者所有。请勿转载和采集!