您的位置:

关于php实现模拟登陆正方教务系统的信息

本文目录一览:

关于php模拟登录网站的问题,一直提示验证码错误

以我的经验,验证码不可能是根据session id来的,那不是每次刷新网页验证码都不变,验证码也失去了验证码的作用.

验证码是需要手动输入的

php能实现模拟登陆吗?

用php模拟登陆主要分为三部分 1. post数据。 2.根据返回的http头,从中截出cookie段。 3.伪造http头发送请求。 我这里以用php抓取163相册的需要密码才能访问的目录为例。 ?php function posttohost($url, $data) //post数据 { $url = parse_url($url); if (!$url) return "couldn't parse url"; if (!isset($url['port'])) { $url['port'] = ""; } if (!isset($url['query'])) { $url['query'] = ""; } $encoded = ""; foreach ($data as $k=$v) { $encoded .= ($encoded ? "" : ""); $encoded .= rawurlencode($k)."=".rawurlencode($v); } $fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80); if (!$fp) return "Failed to open socket to $url[host]"; fputs($fp, sprintf("POST %s%s%s HTTP/1.0\n", $url['path'], $url['query'] ? "?" : "", $url['query'])); fputs($fp, "Host: $url[host]\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: " . strlen($encoded) . "\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, "$encoded\n"); $line = fgets($fp,1024); if (!eregi("^HTTP/1\.. 200", $line)) return; $results = ""; $inheader = 1; while(!feof($fp)) { $line = fgets($fp,1024); if ($inheader ($line == "\n" || $line == "\r\n")) { $inheader = 0; } elseif ($inheader) { $results .= $line; } } fclose($fp); return $results; }

怎么用php模拟登陆

php 模拟登陆,可以使用 curl,以下是示例代码:

$post = "name=2userType=1passwd=asdfloginType=1rand=6836imageField.x=25imageField.y=7";    

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://网址/login.action");

curl_setopt($ch, CURLOPT_HEADER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);

$result=curl_exec($ch);

curl_close($ch);

php模拟登陆教务系统,如何绕过验证码,是正方的说,

把验证码功能去了不久结了,如果你想保留验证但又不想自己登陆的时候输入验证码,那你就判断一下,哪个账号登陆地时候就不执行验证码验证功能。

怎么用PHP模拟登录教务系统,实现查课表和查成绩,最好有例子和源码,谢谢了?

前几天刚实现了一个,难点主要有3块:

1:http头部模拟

2:在使用curl做POST的时候, 当要POST的数据大于1024字节的时候, curl并不会直接就发起POST请求, 而是会分为俩步,

3:post的数据,有几个字段是用js计算出的,需要用php模拟出

附:curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($data));