php 带cookie采集某页面

<?php
error_reporting(0);
define("temp_dir", dirname(__FILE__)."/Public/");
define("U", "11111");//$_GET[‘e‘];
define("P", "mima");

$dlfk=login(U, P);
echo $dlfk;  //登陆


$bbb=friendshow();
$bbb = preg_replace(‘/<script[^>]*?>(.*?)<\/script>/is‘,"",$bbb);
$bbb = preg_replace(‘/<input[^>]*?>/is‘,"",$bbb);
$bbb = preg_replace(‘/<a style[^>]*?>(.*?)<\/a>/is‘,"",$bbb);
$bbb = preg_replace(‘/<a[^>]*?>(.*?)<\/a>/is‘,"",$bbb);
$bbb = str_replace("href=\"style",‘href="http://www.过滤.com/newsimage/style‘,$bbb);
echo $bbb;    //利用获取的COOKIE直接查看页面


function login($uid, $passwd)
{
    $user_agent = "Baiduspider+(+http://www.baidu.com/search/spider.htm)";
    $url = "http://www.你需要登陆的网址.com/save.aspx?action=login&username={$uid}&pwd={$passwd}";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, temp_dir . $uid . ".blu");
    curl_setopt($ch, CURLOPT_COOKIEJAR, temp_dir . $uid . ".blu");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

function friendshow()
{
    $user_agent = "Baiduspider+(+http://www.baidu.com/search/spider.htm)";
    $ch = curl_init("http://www.juhutang.com/");
    curl_setopt($ch, CURLOPT_COOKIEFILE, temp_dir . "cookie.tmp");
    curl_setopt($ch, CURLOPT_COOKIEJAR, temp_dir . "cookie.tmp");
    curl_setopt($ch, CURLOPT_REFERER, $user_agent); //伪造来路
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
    //var_dump($data);
}

?>

 

 

这个是本人原创,嘿嘿。。。。。

php 带cookie采集某页面,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。