Re: Snoopy 用来模仿web浏览器的功能,它能完成获取网页内容和发送表单的任务
PHP代码
[code]<?
//echo var_dump($_SERVER);
include("Snoopy.class.php");
$snoopy = new Snoopy;
$snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1";//这项是浏览器信息,前面你用什么浏览器查看cookie,就用那个浏览器的信息(ps:$_SERVER可以查看到浏 览器的信息)
$snoopy->referer = "http://bbs.phpchina.com/index.php";
$snoopy->expandlinks = true;
$snoopy->rawheaders["COOKIE"]="__utmz=17229162.1227682761.29.7.utmccn=(referral)|utmcsr=phpchina.com|utmcct=/html/index.html|utmcmd=referral; cdbphpchina_smile=1D2D0D1; cdbphpchina_cookietime=2592000; __utma=233700831.1562900865.1227113506.1229613449.1231233266.16; __utmz=233700831.1231233266.16.8.utmccn=(referral)|utmcsr=localhost:8080|utmcct=/test3.php|utmcmd=referral; __utma=17229162.1877703507.1227113568.1231228465.1231233160.58; uchome_loginuser=sinopf; xscdb_cookietime=2592000; __utmc=17229162; __utmb=17229162; cdbphpchina_sid=EX5w1V; __utmc=233700831; cdbphpchina_visitedfid=17; cdbphpchinaO766uPYGK6OWZaYlvHSuzJIP22VpwEMGnPQAuWCFL9Fd6CHp2e%2FKw0x4bKz0N9lGk; xscdb_auth=8106rAyhKpQL49eMs%2FyhLBf3C6ClZ%2B2idSk4bExJwbQr%2BHSZrVKgqPOttHVr%2B6KLPg3DtWpTMUI4ttqNNVpukUj6ElM; cdbphpchina_onlineusernum=3721";
$snoopy->fetch("http://bbs.phpchina.com/forum-17-1.html");
$n=ereg_replace("href=\"","href=\"http://bbs.phpchina.com/",$snoopy->results );
echo ereg_replace("src=\"","src=\"http://bbs.phpchina.com/",$n);
?> [/code]
这 是模拟登陆PHPCHINA论坛的过程,首先要查看自己浏览器的信息:echo var_dump($_SERVER);这句代码可以看到自己浏览器的信息,把 $_SERVER['HTTP_USER_AGENT']后边的内容复制下来,粘在$snoopy->agent的地方,然后就是要查看自己的 COOKIE了,用自己在论坛的账号登陆论坛后,在浏览器地址栏里输入 javascript:document.write(document.cookie),回车,就可以看到自己的cookie信息,复制粘贴 到$snoopy->rawheaders["COOKIE"]=的后边。(我的cookie信息为了安全起见已经删除了一段内容)
然后再注意:
[code]
# $n=ereg_replace("href=\"","href=\"upload/200905122354140503.png" width="500" border="0" />[/code]
注意看地址栏地址,是我本地测试的地址,是不是和真实登陆论坛一模一样?够山寨~爽。我的初步研究就这些,有新进展了再和大家交流。