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

WBOY
Release: 2016-06-13 12:27:02
Original
1259 people have browsed it

使用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 />
Copy after login


请大神指点一下,好像是登录失败,无法获取登录后的主界面
------解决思路----------------------
不会玩就看文档。不会玩至少应该先看看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
Copy after login



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
Copy after login



看清楚了吗?GET登陆的?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template