码迷,mamicode.com
首页 > Web开发 > 详细

php 带cookie采集某页面

时间:2014-08-08 18:06:16      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   ar   cti   

<?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采集某页面,布布扣,bubuko.com

php 带cookie采集某页面

标签:style   blog   http   color   os   io   ar   cti   

原文地址:http://www.cnblogs.com/php411161555/p/3899768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!