擅长:python、mysql、java
<p>您会发现处理<a href="http://docs.python-requests.org/en/latest/" rel="nofollow">requests</a>库比<code>urllib2</code>好得多。在</p>
<p>看看你提供的链接,它不需要基本身份验证,而是一个表单。。。因此,您需要获取表单的“action”属性的URL,并向其提交数据。使用请求的示例:</p>
<pre><code>import requests
url = 'http://www.content.alternative.ac.nz/index.php/alternative/login/signIn'
r = requests.post(url, data={'username': 'username', 'password': 'password', 'remember': '1'})
</code></pre>
<p>我不能完全检查(因为我没有有效的u&p;p),但是通过有效地发送勾选“记住我”按钮,您应该可以通过<code>r.cookies</code>获得一个cookie,这意味着它可以用于进一步的请求,例如:</p>
^{pr2}$