snoopyを使ってログイン-ログイン失敗-マルチドメイン名ジャンプをシミュレートします
コードは次のとおりです:
<br /><?php<br />require_once("Snoopy.class.php");<br />$snoopy = new Snoopy;<br />$snoopy->agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0"; <br />$snoopy->referer = "http://agent.fang.com/";<br />$snoopy->rawheaders["Pragma"] = "no-cache";<br />$snoopy->maxredirs = 2;//重定向次数<br />$snoopy->offsiteok = false;<br />$snoopy->user = "esf-agen42249";<br />$snoopy->pass = "dlesf2010";<br />$submit_url = "http://agent.fang.com/DealLoginAjax.aspx";<br />$submit_vars["str_username"] = "esf-agen42249";<br />$submit_vars["str_userpwd"] = "dlesf2010";<br />$submit_vars["str_imgCode"] = "请输入验证码";<br />$snoopy->submit($submit_url,$submit_vars);<br />$snoopy->setcookies();<br />if($snoopy->fetch("http://b.agent.fang.com/magent/HomePage.aspx")){<br /> print_r($snoopy->headers);<br /> print_r($snoopy->cookies);<br /> echo("<hr/>");<br />// print_r($snoopy->results);//无法获取登录后才能看到的页面<br />}else<br /> echo "error: ".$snoopy->error."\n";<br />?><br />
Remote Address:111.40.195.21:80<br />Request URL:http://agent.fang.com/DealLoginAjax.aspx?str_username=esf-agen42249&str_userpwd=571c041891354cc5b51725f0b37170f80efb4f27ba8c897e4ff67ebe17b4ce599f28ac5f7eceeb5ff2d9755c62a57db74f206d3c52ccb79b71c24e3858f29ac7d49dfb8d77192529ac387b4e9c6426ecf70f3003ce348dcd6bd4d1af84e9293164516745c654d2c9bc0089c80f02ba5f69aeaac1e142c8af8e000ac7b1a4a278&str_imgCode=%E8%AF%B7%E8%BE%93%E5%85%A5%E9%AA%8C%E8%AF%81%E7%A0%81<br />Request Method:GET<br />Status Code:200 OK
str_username=esf-agen42249&str_userpwd=571c041891354cc5b51725f0b37170f80efb4f27ba8c897e4ff67ebe17b4ce599f28ac5f7eceeb5ff2d9755c62a57db74f206d3c52ccb79b71c24e3858f29ac7d49dfb8d77192529ac387b4e9c6426ecf70f3003ce348dcd6bd4d1af84e9293164516745c654d2c9bc0089c80f02ba5f69aeaac1e142c8af8e000ac7b1a4a278&str_imgCode=%E8%AF%B7%E8%BE%93%E5%85%A5%E9%AA%8C%E8%AF%81%E7%A0%81