我想通过curllib登录我的university webmail页面。
为此,我编写了以下代码:
$url = 'http://eetd.kntu.ac.ir/mda2.asp';
$reffer = 'http://sabamail.kntu.ac.ir:3000/WorldClient.dll?View=Main';
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$cookie_file_path = "/var/www/cookie.txt";
$post_fields = 'dom=ee.kntu.ac.ir&usr=hoseini&password=*****';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch,CURLOPT_REFERER,$reffer);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec($ch);
curl_close($ch);
echo $result;但是它会再次重定向到1,而不会显示您的密码是错误的!问题出在哪里?
发布于 2011-09-28 00:32:52
网站上说:
<input type="password" name="pd" size="18">您可以设置:
$post_fields = 'dom=ee.kntu.ac.ir&usr=hoseini&password=*****';将密码更改为pd
发布于 2011-09-28 00:31:32
如果您实际检查登录页面的源代码,您会发现password元素名为pd,而不是password。
因此,您需要更改以下内容:
$post_fields = 'dom=ee.kntu.ac.ir&usr=hoseini&password=*****';...to此命令:
$post_fields = 'dom=ee.kntu.ac.ir&usr=hoseini&pd=*****';这可能不是唯一的问题,但它肯定是一个问题。
https://stackoverflow.com/questions/7572216
复制相似问题