电影资源站采集

admin 1月前 170

<?php
$pg=$_GET['pg'];
if(!$pg)$pg=2;
// API的URL和参数(如果需要的话)
$api_url = 'https://api.apibdzy.com/api.php/provide/vod/';
$parameters = array(
    'ac' => 'detail',
    'pg' => $pg
); 
// 构造GET请求时URL中的查询字符串
if (!empty($parameters)) {
    $query_string = http_build_query($parameters);
    $api_url .= '?' . $query_string;
}
// 初始化cURL会话
$ch = curl_init();
// 设置cURL选项
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 将cURL的结果作为字符串返回,而不是直接输出
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); // 如果API需要JSON格式,设置请求头
// 可能需要添加其他选项,如认证信息、超时等
// 执行cURL请求
$response = curl_exec($ch);
// 检查请求是否成功
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    // 获取HTTP响应码
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    if ($http_code == 200) { // 成功响应
        // 解析返回的JSON数据
        $json_data = json_decode($response, true); // 第二个参数为true以返回关联数组
        
//var_dump($json_data);
//print_r($json_data['list'][0]);
echo "pagecount:".$json_data['pagecount']."<br>";
echo "u/page:".$json_data['limit']."<br>";
echo "total:".$json_data['total']."<br>";
        // 处理API返回的数据
        foreach ($json_data['list'] as $item) {
            // 这里假设API返回的是一个数组,你可以根据实际结构进行解析
            echo "Item ID: " . $item['vod_name'] . "<br>";
$old_url = "https://pic1.bdzyimg.com";
$new_url = "https://www.bdzy.com";
$vod_pic = str_replace($old_url, $new_url, $item['vod_pic']);
echo $vod_pic;
$cid=1;
$post_data = array (
    "cid" => $cid,
    "content" => $item['vod_content'],
    "description" => $item['vod_blurb'],	
    "title" =>  $item['vod_name'],
    "pic" =>  $vod_pic,
    "actor" => $item['vod_actor'],
    "director" =>  $item['vod_director'],
    "area" =>  $item['vod_area'],
    "lang" =>  $item['vod_lang'],
    "year" =>  $item['vod_year'],	
    "play_from" =>  $item['vod_play_from'],
    "play_url" =>  $item['vod_play_url'],
    "type_name" =>  $item['type_name']	
);
$urls = array(
 'http://b.xiansitan.com/post/'
); // 设置要抓取的页面URL   
foreach ($urls as $i => $url) {    
send_post($url, $post_data);  
} 
        }
    } else {
        echo "HTTP Error: " . $http_code;
    }
}
// 关闭cURL会话
curl_close($ch);
$pg++;
	echo "<script>location.href='?pg=".$pg."'</script>";
function send_post($url, $post_data) {  
   
  $postdata = http_build_query($post_data);  
  $options = array(  
    'http' => array(  
      'method' => 'POST',  
      'header' => 'Content-type:application/x-www-form-urlencoded',  
      'content' => $postdata,  
      'timeout' => 15 * 60 // 超时时间(单位:s)  
    )  
  );  
  $context = stream_context_create($options);  
  $result = file_get_contents($url, false, $context);  
   
  return $result;  
}  
   
?>


欢迎联系本站长QQ:3216572
最新回复 (1)
  • admin 1月前
    2
    -- Adminer 4.7.0 MySQL dump
    
    SET NAMES utf8;
    SET time_zone = '+00:00';
    SET foreign_key_checks = 0;
    SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
    
    SET NAMES utf8mb4;
    
    DROP TABLE IF EXISTS `article_template_article`;
    CREATE TABLE `article_template_article` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `cid` int(11) NOT NULL DEFAULT '0',
      `uid` int(11) NOT NULL DEFAULT '0',
      `title` varchar(255) DEFAULT NULL,
      `keywords` varchar(255) DEFAULT NULL,
      `description` longtext,
      `content` longtext,
      `recommend` int(1) DEFAULT NULL,
      `datetime` bigint(10) DEFAULT NULL,
      `pic` varchar(255) DEFAULT NULL,
      `actor` varchar(255) DEFAULT NULL,
      `director` varchar(255) DEFAULT NULL,
      `area` varchar(255) DEFAULT NULL,
      `lang` varchar(255) DEFAULT NULL,
      `year` varchar(255) DEFAULT NULL,
      `play_from` varchar(255) DEFAULT NULL,
      `play_url` longtext,
      `type_name` varchar(255) DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `cid` (`cid`),
      KEY `uid` (`uid`),
      KEY `recommend` (`recommend`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    
    
    -- 2024-06-03 03:54:12


返回