把下面代码改成获取httpcf228e76e6hk02hoomooncnapi这个接口输出的mp4视频文件然后下载php 下载文件的目录$download_dir = ; 获取文件内容$file_content = file_get_contentshttpsapiuunlcnAPIapi-girlvideosmztxt; 将文件内容按行分割成数组$lines = exploden $file_c
$line) {
// 去除空白字符
$line = trim($line);
// 如果链接为空,则跳过
if (empty($line)) {
continue;
}
// 生成随机文件名
$file_name = generate_random_file_name();
// 下载视频文件
download_file($line, $download_dir . $file_name . '.mp4');
}
/**
* 生成随机文件名
*/
function generate_random_file_name()
{
$characters = 'abcdefghijklmnopqrstuvwxyz';
$file_name = '';
for ($i = 0; $i < 8; $i++) {
$file_name .= $characters[rand(0, strlen($characters) - 1)];
}
return $file_name;
}
/**
* 下载文件
*/
function download_file($url, $file_path)
{
$ch = curl_init($url);
$fp = fopen($file_path, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
?>
原文地址: https://www.cveoy.top/t/topic/b7Hh 著作权归作者所有。请勿转载和采集!