Home > Backend Development > PHP Tutorial > php curl模拟登录 https://login.yahoo.co.jp 的有关问题

php curl模拟登录 https://login.yahoo.co.jp 的有关问题

WBOY
Release: 2016-06-13 10:33:17
Original
3162 people have browsed it

php curl模拟登录 https://login.yahoo.co.jp 的问题
代码我基本上写出来了,但是抓去的页面是让输入验证码的
代码如下:
private function login(){
  $is_login = 0;
  $rurl = "http://www.yahoo.co.jp";
  //取随机码
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://login.yahoo.co.jp/config/login");
  curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie_jar);
  curl_setopt($ch, CURLOPT_HEADER,1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  $tmp = curl_exec($ch);
  //curl_close($ch);
  preg_match('//i', $tmp, $mchallenge);
  preg_match('//i', $tmp, $mu);
  preg_match('//is',$tmp,$malbatross);

  $challenge = $mchallenge[1];
  $u = $mu[1];
  $albatross = $malbatross[1];
  //print_r($cookie_jar);exit;
  //print_r($arr);exit;
  //$hash_passwd = md5(md5($this->user_pwd).$challenge);
  //第一步:初步登陆
  //$ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://login.yahoo.co.jp/config/login");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, ".albatross=".$albatross."&.ct="."&.tries=1&.src=&.md5=&.hash&.js=&.last=&promo=&.intl=jp&.bypass=&.partner=&.u=".$u."&.v=0&.challenge=".$challenge."&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=".$rurl."&.pd=&.protoctl=&login=".$this->username."&passwd=".$this->password);//
  curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie_jar);
  curl_setopt($ch, CURLOPT_HEADER,1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  $str = curl_exec($ch);
  curl_close($ch);
  echo $str;exit;
  //判断是否登录成功
  if (strpos($str, "HTTP/1.1 302 Found") !== false){
  $is_login = 1;
  }
  return $is_login;
  }
用户名和密码都有, 但是模拟登录完是让输入验证码的,很郁闷,
soso的大侠们 帮解决下吧,
https://login.yahoo.co.jp/ 里的源代码 name=".albatross" 这个变量和登录有关系,每次刷新页面都会变化, 所以我 估计跟它有关,

------解决方案--------------------
好像不成功~~
------解决方案--------------------
這個費事費力的事情除非有人做過,要不然你可能不能夠在這裏得到答案
------解决方案--------------------
输入验证码的




无解了。

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