对于一个计算机科学项目,我们必须建立一个展示我们时间安排的网站。所以基本上我们要做的就是登录这个站点并从你被引导到的页面中获取信息。我已经阅读了很多帖子并尝试了很多 cURL,但似乎没有任何效果。我得到了要填写的表格,但看起来好像没有点击“提交”按钮。这就是我所拥有的:
<?php
$url="http://rooster.sgnphp.nl/infoweb/index.php";
$post_data['user'] = '105353';
$post_data['paswoord'] = '105353';
foreach ( $post_data as $key => $value)
{
$post_items[] = $key . '=' . $value;
}
$postdata = implode ('&', $post_items);
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, cookie.txt);
curl_setopt ($ch, CURLOPT_COOKIEFILE, cookie.txt);
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
?>
我尝试填写的表格如下所示:
<form action="/infoweb/index.php" method="post">
<input type="hidden" name="csrf" value="cec30a2ed764e956ed01f137e2f0705a">
<table>
<tbody><tr>
<td>
Gebruikersnaam:
</td>
<td>
<input class="mooi" style="color: #FF8080;" type="text" name="user" value="105353" onfocus="if (this.value =='username') this.value=''; this.style.color='#000000';" onkeydown="this.style.color='#000000';">
</td>
</tr>
<tr>
<td>
Wachtwoord:
</td>
<td>
<input class="mooi" style="margin-bottom: 2px; color: #FF8080;" type="password" name="paswoord" value="105353" onfocus="if (this.value =='wachtwoord') this.value=''; this.style.color='#000000';" onkeydown="this.style.color='#000000';">
</td>
</tr>
<tr>
<td>
<input type="hidden" name="login" value="loginform">
</td>
<td>
<input type="submit" class="mooi" value="inloggen"><br>
</td>
</tr>
</tbody></table>
</form>
那么会发生什么情况是表格已填写,但我看不到时间表,因为(我认为)我没有正式登录。有人可以帮我吗?我真的需要让它工作,这样我才能继续我的项目的其余部分,但我已经坚持了好几天了。
谢谢