我正在使用PythonMechanize登录这个站点,但是数据似乎是通过HTTP提交的。
我的代码如下所示:
import mechanize
b = mechanize.Browser()
b.open('http://site.com')
form = b.forms().next() # the login form is unnamed...
print form.action # prints "https://login.us.site.com"
form['user'] = "guest"
form['pass'] = "guest"
b.form = form
b.submit()
提交表单时,通过HTTP建立连接,并包含以下内容:
send: 'POST https://login.us.site.com/ HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 180\r\nHost: login.us.site.com\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'...
有人能确认这一点并最终发布解决方案,以便通过HTTPS提交表单吗?
2) 我用Wireshark观察了流量,我可以确认流量是通过正常的HTTP发送的(我可以看到帖子的内容,mechanize不会向代理发送与webbrowser相同的请求,后者发送CONNECT login.us.site.com:443,而mechanize只发送帖子)
https://login.us.site.com
). 但是,我不知道数据离开代理时会发生什么情况;也许它建立了到目标站点的ssl连接?