高价收广告产品,加qq251217411 站长轻松月入过万 加qq185375005赚美元 海外站长日赚200刀

【站长运营】新浪采集解析源码分享

好站长   ·  2018-12-25   ·   源码分享
<?php
error_reporting(0);
header("Content-type: text/json; charset=utf-8");
function get_info($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}
$list='[';
    $html=get_info('https://cre.dp.sina.cn/api/v3/get?cateid=y&cre=tianyi&mod=wfin&merge=3&statics=1&action=1&up=1&down=0&tm=1545720763'); 
    // 模板  页  分类  地址  样式  作者   作者头像   标题   时间  图片 
    $json=json_decode($html); 
    foreach ($json->data as $key => $rows) { 
      $uri=str_replace(array("html?",'http://'), array('html&','https://'), $rows->surl);
        $list .='{"host":"web","type":"qukuailian","page":"1","url":"'.$uri.'","style": "style1","author_name":"'.$rows->author.'","style_img":"'.$rows->thumb.'","title":"'.$rows->title.'","time":"'.date("Y-m-d H:i:s",$rows->ctime).'","img": ["'.$rows->thumb.'","'.$rows->thumb.'","'.$rows->thumb.'"]},';
    }
    $list = $list.']';
    $list=str_replace('},]', '}]', $list);
    echo $list;
?>

少年这只是新闻采集源码不是电影的采集,有兴趣的可以学习下

2 Reply   |  Until 2018-12-31 | 915 View
LoginCan Publish Content