0

我在服务器上有一个 j_security_check 页面,我需要将数据传递给它。我使用 Python urllib2 模块,以 j_username 和 j_password 作为参数发送 POST 请求。问题是我有 HTTPError 408 作为响应:“已超过登录过程允许的时间”。我该怎么办?

4

1 回答 1

2

您可以尝试先获取登录页面并存储 cookie。这个 j_security_check-thingie 看起来像 acegi 安全的东西。

import urllib, urllib2

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor)
urllib2.install_opener(opener)
urllib2.urlopen('http://server/login_form/')
urllib2.urlopen('http://server/j_security_check',
 data=urllib.urlencode({'j_username':'scott','j_password':'wombat'}))
于 2010-11-18T15:50:55.130 回答