时间:2021-07-01 10:21:17 帮助过:4人阅读
$cookie_file = tempnam('./temp','cookie');
$login_url = 'http://210.35.75.247:8080/student/studentFrame.jsp';
$post_fields = 'userName=1101001&passwd=1101001';
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
$url = 'http://210.35.75.247:8080/student/queryCheckInfo.jsp';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_exec($ch);
curl_close($ch);
?>
$url1 = 'http://210.35.75.247:8080/student/studentInfo.jsp';
$url2 = 'http://210.35.75.247:8080/student/queryCheckInfo.jsp';
$name = '1101001';
$pw = '1101001';
$params = array(
'userName' => $name,
'passwd' => $pw,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url1 . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$con = curl_exec($ch);
preg_match('/Set-Cookie: (.*);/Us', $con, $match);
$cookie = $match[1];
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
$con = curl_exec($ch);
curl_close($ch);
echo $con;