您好,欢迎访问一九零五行业门户网

Curl写请求盗取金十网首页数据,附thinkphp源码包

玩了curl后发现php正则真的很重要,可惜我很菜。拿了网页上的三个字段写了个demo。下面贴的代码复制下来可以直接运行。其实就是用别人的数据自己做api的一种思路。
(.+?)/',$datas,$content);  /*对应的所有内容*/
    preg_match_all('/普通新闻|重要新闻|一般数据|重要数据/',$datas,$importance);  /*对应的所有新闻的重要性*/
    $contents=$content[1];           /*对应的所有内容*/
    $times=$time[1];                  /*对应的所有时间*/
    $importances=$importance[0];
$news=[];
    foreach ($contents as $key => $value) {
        $t=[
            content=>$value,
            time=>$times[$key],
            importance=>str_replace('','',$importances[$key]),
        ];
        array_push($news,$t);
    }
    var_dump($news);
?> 109news.rar ( 1.12 mb 下载:7 次 )
其它类似信息

推荐信息