使用snoopy模拟登录-登录失败-多域名跳转解决方法

WBOY
Lepaskan: 2016-06-13 12:27:02
asal
1259 orang telah melayarinya

使用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 />
Salin selepas log masuk


请大神指点一下,好像是登录失败,无法获取登录后的主界面
------解决思路----------------------
不会玩就看文档。不会玩至少应该先看看http请求数据吧?

正常登陆,看HTTP数据传输:
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
Salin selepas log masuk



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
Salin selepas log masuk



看清楚了吗?GET登陆的?

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan