


php模拟登陆教务出现object moved to here,加上了curl_setopt($ch, CURLOPTFOLLOWLOCATION, 1);
学生一个,自己在摸索,希望大神们百忙之中指导一下,不知道到底哪里出现了问题
模拟登陆教务网站出现问题,求教大神们
教务网站http://xk.shnu.edu.cn:82/index.aspx
测试账号120154728 123612
登陆界面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type"/> <title>a</title></head><body><div class="header">绑定学号 </div> <div class="content"> <div class="notice"><br/>初始密码身份证后6位</div> <div class="form"> <form action="http://localhost/ff/post.php" method="post"> <div class="row"> <span class="label">学 号</span><br/> <input class="input" type="text" name="stuno" value="" /><br/> </div> <div class="row"> <span class="label">密 码</span><br/> <input class="input" type="password" name="stupwd" value="" /><br/> </div> <div class="row"> <span class="label">验证码</span><br/> <input class="input" type="text" name="stuyzm" value="" /><br/> </div> <div class="row"> <input class="<strong></strong>" type="submit" value="提交" /> </div> <iframe id='img' src="i.php" scrolling="No" frameborder="0"></iframe> </form></body></html>
获取验证码
<?php$url = "http://xk.shnu.edu.cn:82/ValidateCode.aspx?codeLen=5&aFineness=90&ImgWidth=85&PosX=4&PosY=1&FontFamily=Arial&FontSize=14&FontStyle=3"; $filedir = SITE_PATH."/TMP/Cookies"; $cookie_file = $filedir."/cookie.txt"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); // curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, "10"); header("Content-type:image/gif"); echo curl_exec($ch); curl_close($ch); ?>
post页面
<?php$user=$_POST["stuno"];$password=$_POST["stupwd"];$yzm=$_POST["stuyzm"];//echo $user;//echo $password;//echo $yzm;$cookie_file = tempnam('./temp','cookie');$login_url = 'http://xk.shnu.edu.cn:82/index.aspx';$post_fields = array("cktime"=>"3153600","txtUserID"=>$user,"txtUserPwd"=>$password,"txtValidateCode"=>$yzm); $ch = curl_init($login_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPTFOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_exec($ch); curl_close($ch); $url='http://xk.shnu.edu.cn:82/index.aspx'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPTFOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); $contents = curl_exec($ch); curl_close($ch);?>
回复讨论(解决方案)
大神们 来帮帮忙
CURLOPTFOLLOWLOCATION
应为
CURLOPT_FOLLOWLOCATION
还有就是你的这些代码的执行次序
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
而且你的验证码也不需要curl获取。直接
即可
CURLOPTFOLLOWLOCATION
应为
CURLOPT_FOLLOWLOCATION
还有就是你的这些代码的执行次序
代码执行次序应该是怎样的啊?代码还有其他的问题吗?
现在改好了 没有重定向的信息了 但是页面显示还是不对
而且你的验证码也不需要curl获取。直接
即可
那如何知道验证码是否与网站上的一致?目前进去变成这样子了
curl 访问 http://xk.shnu.edu.cn:82/index.aspx 用于获取 cookie
解析出验证码图片地址
表单页,填写用户信息和验证码值
curl 提交
curl 访问 http://xk.shnu.edu.cn:82/index.aspx 用于获取 cookie
解析出验证码图片地址
表单页,填写用户信息和验证码值
curl 提交
我的流程是这样子的啊 模拟之后的页面 跟直接在地址栏里输入网址 产生的页面一样 根本不是个人的信息
流程中只第一次才有 curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
以后每部都不能有,不然读到的 cookie 会改变
流程中只第一次才有 curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
以后每部都不能有,不然读到的 cookie 会改变
刚接触 还是不理解
意思是 我的post页面里不再需要curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);吗?
而且你的验证码也不需要curl获取。直接
即可
怎么知道验证码需不需要curl获取啊?
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
我的用户名密码验证码数据是不是还是没有传过去啊?
我 #7 没有说清楚吗?
我 #7 没有说清楚吗?
我的流程应该是你说的那个样子啊
他的登录表单里还有两个隐藏域,你也传过去里吗
他的登录表单里还有两个隐藏域,你也传过去里吗
版主 我加上隐藏值了 也还是不行
<?php$user=$_POST["stuno"];$password=$_POST["stupwd"];$yzm=$_POST["stuyzm"];//echo $user;//echo $password;//echo $yzm;$cookie_file = tempnam('./temp','cookie');$login_url = 'http://xk.shnu.edu.cn:82/index.aspx';$post_fields = array("cktime"=>"3153600","__VIEWSTATE"=>"/wEPDwUKMTU3NjIwMDY1MQ9kFgICAw9kFgQCEQ88KwAJAQAPFgQeCERhdGFLZXlzFgAeC18hSXRlbUNvdW50AghkFhBmD2QWAmYPFQQx5pys5a2m5pyf5a2m55Sf5oiQ57up6K+35LqOMjAxNOW5tDHmnIgyNuaXpeafpeivoggwMDAwMDAzMzHmnKzlrabmnJ/lrabnlJ/miJDnu6nor7fkuo4yMDE05bm0MeaciDI25pel5p+l6K+iCDIwMTQwMTE2ZAIBD2QWAmYPFQQ3MjAxMee6p+acrOenkeeUn+WPr+S7peWPguWKoOS4iua1t+W4gumrmOagoeWFseS6q+ivvueoiwgwMDAwMDAzMjcyMDEx57qn5pys56eR55Sf5Y+v5Lul5Y+C5Yqg5LiK5rW35biC6auY5qCh5YWx5Lqr6K++56iLCDIwMTMxMjIwZAICD2QWAmYPFQQd5Yid6YCJMjAxM+W5tDEy5pyI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BFR5cGULKVxTeXN0ZW0uVHlwZUNvZGUsIG1zY29ybGliLCBWZXJzaW9uPTIuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4ORIeDERlZmF1bHRWYWx1ZQVlIGlkX01zZyBpbiAoIHNlbGVjdCBpZF9Nc2cgZnJvbSBYeE1zZ05vdGlmeVJvbGUgd2hlcmUgUm9sZUlkID0gJzAwMDEwMDA1Jykgb3JkZXIgYnkgcmVsZWFzZWRhdGUgZGVzYyAeDlBhcmFtZXRlclZhbHVlZBQrAQECA2RkZGIgE9UDulG9GvRO4dsU+SdCCEFM","__EVENTVALIDATION"=>"/wEWBgKY0u7vCwLT8dy8BQLG8eCkDwKuqciQCQKC3IeGDAKO8J4Nk+MLn7wUWUDvvoz1eyVjqKX9ZAs=","pwuser"=>$user,"pwpwd"=>$password); $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_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_exec($ch); curl_close($ch); $url='http://xk.shnu.edu.cn:82/StudentManage/wfmXsStuBaseUpdate.aspx'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); $contents = curl_exec($ch); curl_close($ch);?>
你在 pos 页面中
$cookie_file = tempnam('./temp','cookie');
你在获取验证码程序中
$cookie_file = $filedir."/cookie.txt";
整个过程中使用了不同的 cookie 文件,显然不能保证 cookie 是一致的
你在 pos 页面中
$cookie_file = tempnam('./temp','cookie');
你在获取验证码程序中
$cookie_file = $filedir."/cookie.txt";
整个过程中使用了不同的 cookie 文件,显然不能保证 cookie 是一致的 我用firebug调试 发现隐藏值没有传进去,为什么啊?
其他的值都有,传输方式跟其他的一样
$user=$_POST["stuno"];$password=$_POST["stupwd"];$yzm=$_POST["stuyzm"];//echo $user;//echo $password;//echo $yzm;$cookie_file = tempnam('./temp','cookie');$login_url = 'http://xk.shnu.edu.cn:82/index.aspx';$post_fields = array("cktime"=>"3153600","__VIEWSTATE"=>"/wEPDwUKMTU3NjIwMDY1MQ9kFgICAw9kFgQCEQ88KwAJAQAPFgQeCERhdGFLZXlzFgAeC18hSXRlbUNvdW50AghkFhBmD2QWAmYPFQQx5pys5a2m5pyf5a2m55Sf5oiQ57up6K+35LqOMjAxNOW5tDHmnIgyNuaXpeafpeivoggwMDAwMDAzMzHmnKzlrabmnJ/lrabnlJ/miJDnu6nor7fkuo4yMDE05bm0MeaciDI25pel5p+l6K+iCDIwMTQwMTE2ZAIBD2QWAmYPFQQ3MjAxMee6p+acrOenkeeUn+WPr+S7peWPguWKoOS4iua1t+W4gumrmOagoeWFseS6q+ivvueoiwgwMDAwMDAzMjcyMDEx57qn5pys56eR55Sf5Y+v5Lul5Y+C5Yqg5LiK5rW35biC6auY5qCh5YWx5Lqr6K++56iLCDIwMTMxMjIwZAICD2QWAmYPFQQd5Yid6YCJMjAxM+W5tDEy5pyIMTLml6XlvIDlp4sIMDAwMDAwMzEd5Yid6YCJMjAxM+W5tDEy5pyIMTLml6XlvIDlp4sIMjAxMzExMjhkAgMPZBYCZg8VBHPlhbPkuo7miJHmoKEyMDEx57qn5pys56eR55Sf5Y+C5Yqg5LiK5rW35biC6auY5qCh5YWx5Lqr6K++56iL6YCJ6K++4oCc56Gu6K6k44CB5aKe6YCJ44CB6YCA5pS56YCJ4oCd5bel5L2c55qE6YCa55+lCDAwMDAwMDMwc+WFs+S6juaIkeagoTIwMTHnuqfmnKznp5HnlJ/lj4LliqDkuIrmtbfluILpq5jmoKHlhbHkuqvor77nqIvpgInor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G9GvRO4dsU+SdCCEFM","__EVENTVALIDATION"=>"/wEWBgKY0u7vCwLT8dy8BQLG8eCkDwKuqciQCQKC3IeGDAKO8J4Nk+MLn7wUWUDvvoz1eyVjqKX9ZAs=","btnLogin"=>"登陆","txtUserID"=>$user,"txtUserPwd"=>$password,"txtValidateCode"=>$yzm);
你在 pos 页面中
$cookie_file = tempnam('./temp','cookie');
你在获取验证码程序中
$cookie_file = $filedir."/cookie.txt";
整个过程中使用了不同的 cookie 文件,显然不能保证 cookie 是一致的
版主 我现在模拟登陆成功了,我后来发现查询成绩不需要验证码
我只是把隐藏值也传进去了 就ok了
但现在又有个问题 就是有时候显示成绩,有时候又是什么都没有

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor