正义潘恩 发表于 2023-6-1 23:22:53

测试

<?php
if(isset($_POST['submit'])) {
    $url = $_POST['url'];
    // 获取输入的链接
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
    $result = curl_exec($ch);
    curl_close($ch);
    preg_match('/video\/(\d+)/', $result, $matches);
    $video_id = $matches;
    // 从链接中提取抖音视频ID
    $url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $video_id;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
    $result = curl_exec($ch);
    curl_close($ch);
    $data = json_decode($result, true);
    $video_url = $data['item_list']['video']['play_addr']['url_list'];
    $video_url = str_replace('playwm', 'play', $video_url);
    $filename = 'video.mp4';
    // 视频保存的文件名
    file_put_contents($filename, file_get_contents($video_url));
    // 下载抖音无水印视频
    echo '视频下载成功!';
}
?>

<form method="post">
    <input type="text" name="url" placeholder="请输入抖音无水印视频链接">
    <input type="submit" name="submit" value="下载">
</form>
页: [1]
查看完整版本: 测试