首页 > 代码库 > 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);}?>
这个是本人原创,嘿嘿。。。。。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。