首页 > 代码库 > php 带cookie采集某页面

php 带cookie采集某页面

<?phperror_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=http://www.mamicode.com/"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);}?>

 

 

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