欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

phpcurl模拟登陆教务失败

程序员文章站 2022-05-16 23:00:40
...
php

header("charset:gb2312");

$cookie_file_code= tempnam('../temp','1');
$cookie_file= tempnam('../temp','cookie');

$verify_code="http://jwgl.nchu.edu.cn/%28A%28Tp6UeVNz0AEkAAAAMDUxNzI3MzYtMzllNi00NzYyLWE1YzQtN2FmMTIwMWQzZTBkrrvMP29Y-yBw_vP8XbLBAJRblDc1%29%29/VerifyCode.aspx";

$login_url="http://jwgl.nchu.edu.cn/%28A%28jXk8-lVz0AEkAAAAMzFkZDQzOTgtOGJjMy00Zjk2LWFhOWUtZmU1NjFkMzI5ZDVhNcZtD14t-KwNiEt5JEo2btqwucE1%29%29/login.aspx";
$login_url=" http://jwgl.nchu.edu.cn/(A(EWyseVNz0AEkAAAAZmFhM2ZhMzAtZmE0Zi00ZTFhLWI4NDctM2Y2YmZiOWU3YTBj7Kl0PO135gewCK6G-w4baXWOzRg1))/WebResource.axd?d=783PulS-qGHg_IAVaRGUub4wwcxPD5ewvL1lfSB-H5ucFuL0J2saUXZR4r4yVo2hdwJBcM_eqVjKsqb0J_T3lYqyUxApDxhRBBBQ7GC1QwTnH1-n6ghXcBwR5uNg7yktUvDE7wWctq-8i92vjRij39e-M1uCDOd8kCvnBATnpVzVxpY-ZlSK1dH9Kn43Z086Yt6GyQ2&t=633918190284687500 ";

$char=curl_init($verify_code);
curl_setopt($char, CURLOPT_HEADER, 0);
curl_setopt($char, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($char, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($char, CURLOPT_COOKIEJAR, $cookie_file_code);
curl_setopt($char, CURLOPT_COOKIESESSION, 1);

$verify=curl_exec($char);

curl_close($char);

$login="__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=/wEPDwUKMTAxODAxOTQxOQ9kFgICAw9kFhICAw8PFgIeBFR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QWAgUJdGNjZWxsMl8wD2QWAgUHY2VsbDJfMA9kFgQCAQ8PFgQfAAU25a2m55Sf5YeM5bGV5pWZ5Yqh57O757uf5a+G56CB5om+5Zue5pa55rOVKDExIDEwIDIwMTQpHw8FSVN5c3RlbVRvb2wvU1ROZXdzRGV0YWlsc1Nob3cuYXNweD9JZD03ZTkxYmM0YS0xNGJmLTRhNGMtODIwOC0xZGFkNjE1Y2NjOTlkZAIDDw8WAh4HVmlzaWJsZWhkZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAgULY29iUm9sZSREREQFB2dyaWROZXfEjRSrtzrEpPK1LD63AI4mB6SRXA==&__VIEWSTATEGENERATOR=C2EE9ABB&__EVENTVALIDATION=/wEWCAL7u6fsDgLLrZqPCAKqydOsDAKjp/vdAQLzpqn0DwLs9tTtBQKM54rGBgLXk6LaBmtsI0tjk61T0XI02z9K6rBtcLeF&cobRole_DDD_LInsertedItems=&cobRole_DDD_LCustomCallback=&cobRole_DDD_L_VI&User_ID=138206116&User_Pass=shwan1995";
$ch=curl_init($login_url);

curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt($ch, CURLOPT_HTTPHEADER, 0);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_REFERER, "http://jwgl.nchu.edu.cn/(A(EWyseVNz0AEkAAAAZmFhM2ZhMzAtZmE0Zi00ZTFhLWI4NDctM2Y2YmZiOWU3YTBj7Kl0PO135gewCK6G-w4baXWOzRg1))/WebResource.axd?d=shwan1995&t=138206116");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_ENCODING ,'gzip');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $login);
//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_code);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);

//curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
$contents=curl_exec($ch);

curl_close($ch);

?>

相关标签: php