如何下载需要用户名和密码的网页?
例如,我想在插入用户名和密码后下载此页面:
http://forum.ubuntu-it.org/
我已尝试使用 wget 但不起作用。
有 python 的解决方案吗?
您可以使用这些用户名和密码进行测试:
username: johnconnor
password: hellohello
For example, I want to download this page after inserting username and password:
http://forum.ubuntu-it.org/
I have tryed with wget but doesn't work.
Is there a solution with python ?
You can test with these username and password:
username: johnconnor
password: hellohello
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 urllib2 模块,这样就可以进行基本和基于表单的身份验证(有 cookie 支持)。
这是关于您的问题的一个很好的教程。
You can use the urllib2 module and with that it is possible do to basic and form based authentication (with cookies support).
Here is a nice tutorial on your issue.
就像@robert 说的,使用机械化。
让您开始:
Like @robert says, use mechanize.
To get you started:
尝试 mechanize 模块。它基本上是一个编程浏览器界面。
Try the mechanize module. It's basically a programmatic browser interface.