我正在尝试这个python脚本:
import httplib
import urllib
conn = httplib.HTTPConnection("moodle.tau.ac.il")
conn.request("POST" , "/hu11/?lang=en_utf8&username=bugs&password=bunny" )
response = conn.getresponse()
print response.status, response.reason
print response.read()
conn.close()
但它不会像我想的那样登录网站。我想构建一些脚本来帮助朋友从他的课程中下载所有文件。
在向服务器设置发布请求时我做错了什么?
我在网站上有这个表单标签我想用python脚本登录:
<form action="" method="post" id="login">
<div class="loginform">
<div class="form-label"><label for="username">Username</label></div>
<div class="form-input">
<input type="text" name="username" id="username" size="8" maxlength=8 value="" />
</div>
<div class="clearer"><!-- --></div>
<div class="form-label"><label for="password">Password</label></div>
<div class="form-input">
<input type="password" name="password" id="password" size="5" value="" />
<br /><br />
<input type="submit" value="Login" />
<input type="hidden" name="testcookies" value="0" />
</div>
<div class="clearer"><!-- --></div>
</div>
</form>