开发完事之后,登陆是可以的,但是后来一直提示
array
(
[username] => 请刷新页面后重新提交
)
这个不知道是怎么回事,一直没找到什么原因,郁闷
话不多说,上代码,盼望做过的英雄帮忙下,
headers[] = 'accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; $this->headers[] = 'connection: keep-alive'; //$this->headers[] = 'content-type: application/x-www-form-urlencoded;charset=utf-8'; //$this->headers[] = ''; } $this->user_agent = 'mozilla/4.0 (compatible; msie 7.0; windows nt 5.1; .net clr 1.0.3705; .net clr 1.1.4322; media center pc 4.0)'; $this->compression=$compression; $this->proxy=$proxy; $this->cookies=$cookies; if ($this->cookies == true) $this->cookie($cookie); } function cookie($cookie_file) { if (file_exists($cookie_file)) { $this->cookie_file=$cookie_file; } else { if($h = fopen($cookie_file,'w')){ $this->cookie_file=$cookie_file; fclose($h); } else { $this->error('the cookie file could not be opened. make sure this directory has the correct permissions'); } } } function get($url) { $process = curl_init($url); curl_setopt($process, curlopt_httpheader, $this->headers); curl_setopt($process, curlopt_header, 0); curl_setopt($process, curlopt_useragent, $this->user_agent); if ($this->cookies == true) curl_setopt($process, curlopt_cookiefile, $this->cookie_file); if ($this->cookies == true) curl_setopt($process, curlopt_cookiejar, $this->cookie_file); curl_setopt($process,curlopt_encoding , $this->compression); curl_setopt($process, curlopt_timeout, 30); if ($this->proxy) curl_setopt($process, curlopt_proxy, $this->proxy); curl_setopt($process, curlopt_returntransfer, 1); curl_setopt($process, curlopt_followlocation, 1); $return = curl_exec($process); curl_close($process); return $return; } function post($url,$data) { $process = curl_init($url); curl_setopt($process, curlopt_httpheader, $this->headers); curl_setopt($process, curlopt_header, 0); curl_setopt($process, curlopt_useragent, $this->user_agent); if ($this->cookies == true) curl_setopt($process, curlopt_cookiefile, $this->cookie_file); if ($this->cookies == true) curl_setopt($process, curlopt_cookiejar, $this->cookie_file); curl_setopt($process, curlopt_encoding , $this->compression); curl_setopt($process, curlopt_timeout, 30); if ($this->proxy) curl_setopt($process, curlopt_proxy, $this->proxy); curl_setopt($process, curlopt_postfields, $data); curl_setopt($process, curlopt_returntransfer, 1); curl_setopt($process, curlopt_followlocation, 1); curl_setopt($process, curlopt_post, 1); $return = curl_exec($process); curl_close($process); return $return; } function vpost($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个curl会话 //$this->headers[] = 'content-type: application/x-www-form-urlencoded;charset=gbk'; curl_setopt($curl, curlopt_httpheader, $this->headers); curl_setopt($curl, curlopt_url, $url); // 要访问的地址 curl_setopt($curl, curlopt_ssl_verifypeer, 0); // 对认证证书来源的检查 curl_setopt($curl, curlopt_ssl_verifyhost, 1); // 从证书中检查ssl加密算法是否存在 curl_setopt($curl, curlopt_useragent, $this->user_agent); // 模拟用户使用的浏览器 //curl_setopt($curl, curlopt_nobody, 0); if ($this->cookies == true) curl_setopt($curl, curlopt_cookiefile, $this->cookie_file);; if ($this->cookies == true) curl_setopt($curl, curlopt_cookiejar, $this->cookie_file); curl_setopt($curl, curlopt_followlocation, 1); // 使用自动跳转 curl_setopt($curl, curlopt_autoreferer, 1); // 自动设置referer curl_setopt($curl, curlopt_post, 1); // 发送一个常规的post请求 curl_setopt($curl, curlopt_postfields, $data); // post提交的数据包 curl_setopt($curl, curlopt_timeout, 30); // 设置超时限制防止死循环 curl_setopt($curl, curlopt_header, 0); // 显示返回的header区域内容 curl_setopt($curl, curlopt_returntransfer, 1); // 获取的信息以文件流的形式返回 $tmpinfo = curl_exec($curl); // 执行操作 if (curl_errno($curl)) { echo 'errno'.curl_error($curl);//捕抓异常 } curl_close($curl); // 关闭curl会话 return $tmpinfo; // 返回数据 } function vget($url){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个curl会话 //$this->headers[] = 'content-type: application/x-www-form-urlencoded;charset=gbk'; curl_setopt($curl, curlopt_httpheader, $this->headers); curl_setopt($curl, curlopt_url, $url); // 要访问的地址 curl_setopt($curl, curlopt_ssl_verifypeer, 0); // 对认证证书来源的检查 curl_setopt($curl, curlopt_ssl_verifyhost, 1); // 从证书中检查ssl加密算法是否存在 curl_setopt($curl, curlopt_useragent, $this->user_agent); // 模拟用户使用的浏览器 //curl_setopt($curl, curlopt_nobody, 0); if ($this->cookies == true) curl_setopt($curl, curlopt_cookiefile, $this->cookie_file);; if ($this->cookies == true) curl_setopt($curl, curlopt_cookiejar, $this->cookie_file); curl_setopt($curl, curlopt_followlocation, 1); // 使用自动跳转 curl_setopt($curl, curlopt_autoreferer, 1); // 自动设置referer //curl_setopt($curl, curlopt_post, 0); // 发送一个常规的post请求 //curl_setopt($curl, curlopt_postfields, $data); // post提交的数据包 curl_setopt($curl, curlopt_timeout, 30); // 设置超时限制防止死循环 curl_setopt($curl, curlopt_header, 1); // 显示返回的header区域内容 curl_setopt($curl, curlopt_returntransfer, 1); // 获取的信息以文件流的形式返回 $tmpinfo = curl_exec($curl); // 执行操作 if (curl_errno($curl)) { echo 'errno'.curl_error($curl);//捕抓异常 } curl_close($curl); // 关闭curl会话 return $tmpinfo; // 返回数据 } function error($error) { echo util_curl error
$error
; die; }}$shopuser = array();$shopuser['name'] = 'xxxx';$shopuser['password'] = 'xxxxxxxxx';$cookiefile = './cookie_aaa.txt';$http = new util_curl(true,$cookiefile);//1.获取登录页面代码,从中找出uuid变量值$showloginurl = https://passport.jd.com/new/login.aspx;$loginviewstr = $http->vget($showloginurl);preg_match('/vpost($loginurl,$fields);$jsonobj = json_decode(str_replace(array('(',')'),'',$response),true);if(isset($jsonobj['success'])) echo '登陆成功';print_r($jsonobj);exit;
回复讨论(解决方案) 没有做过这个的人吗
需要输入验证码吧
我是用易语言写,但方法基本一样,也是提示“请刷新页面后重新提交”,我看抓的提交数据包是:
“uuid=”+uuid+“&loginname=+用户名+&nloginpwd=+密码+&loginpwd=+密码+&machinenet=&machinecpu=&machinedisk=&authcode=&mjodprgwfp=dkndp”
主要是authcode=后面还有一个mjodprgwfp=dkndp的东西,应该它是有用处的,如果我们不能正确提交这个数据就会被判无效吧,唉,我也研究不出来。
我的q 957997543
cookie 缓存文件名应使用绝对路径
但即便是这样做了,也不能保证成功
京东应该和淘宝一样,使用了 js 操控第三方验证服务。所以的的程序不能解析和执行 js 的话,成功的概率为 0
这个
http://blog.csdn.net/jdgdf566/article/details/13632111
恐怕也起不了作用。既然原因如4楼说的的话。
不知楼主解决了没有,我也遇到同样问题!
楼主解决了吗?同求解决方案
楼主问题解决了么?求解决方案
京东用了flashcookie,不好获取,我用c++ builder搞半天也没取出关键cookie:
track=c09a16fa-8dfd-015b-b289-1372d4c03405
只要得到这个cookie其他的就好办了。
楼主 解决的吗 求分享成果
看一下单点登陆的过程就知道淘宝和京东如何获取这些信息了。