python 登录验证
2015-10-14 15:42
555 查看
python请求服务器数据,验证用户名和密码,除了常用的HTTPBasicAuthHandler,还有HTTPDigestAuthHandler,可以通过fiddler抓包,查看服务器返回数据中的验证字段,如果是Digest验证,返回的格式的应该是
python 请求数据的方法是:(使用urllib和urllib2)
参考:
http://www.th7.cn/Program/Python/201411/310230.shtml
https://zindilis.com/blog/2012/08/15/login-in-to-website-with-digest-authentication-in-python.html
http://blog.163.com/hlz_2599/blog/static/1423784742013415101252410/
Basic验证和Digest验证的设置方式
http://blog.jobbole.com/41519/
HTTP/1.1 401 Unauthorized Connection: close WWW-Authenticate: Digest qop="auth", realm="example", nonce="1444807486_3232235838"
python 请求数据的方法是:(使用urllib和urllib2)
import urllib import urllib2 url_top = "http://www.example.com" url = "http://www.example.com/index.html" auth = urllib2.HTTPDigestAuthHandler() #根据服务器要求的验证方法,选择对应的handler auth.add_password(realm,url_top,username,password) opener = urllib2.build_opener(auth) urllib2.install_opener(opener) res_data = urllib2.urlopen(url) res = res_data.read() print res
参考:
http://www.th7.cn/Program/Python/201411/310230.shtml
https://zindilis.com/blog/2012/08/15/login-in-to-website-with-digest-authentication-in-python.html
http://blog.163.com/hlz_2599/blog/static/1423784742013415101252410/
Basic验证和Digest验证的设置方式
http://blog.jobbole.com/41519/
相关文章推荐
- <LeetCode><Easy>258Add Digits
- <LeetCode><Easy>263 Ugly Number (因式分解)
- python安装-ubuntu之第一篇
- 操作RPM和DEB包的PYTHON模块
- Python循环语句之break与continue的用法
- python2.7安装
- Python实现的内存表
- python flask 部署
- python-web.py-api文档
- Python编程中的for循环语句学习教程
- python基础学习笔记-正则表达式
- python代码风格建议
- 在Python的while循环中使用else以及循环嵌套的用法
- python学习
- python 编码问题
- Python - 编码转换
- <LeetCode><Easy>278First Bad Version (二分查找)
- 使用minidom来处理XML的示例(Python 学习)(转载)
- python 环境下的服务器压力测试工具boom
- pythonmode英文说明书