python ____opendirector类
来源:互联网 发布:深圳网络固定地址 编辑:程序博客网 时间:2024/06/03 04:13
当你获取一个URL时,你使用一个opener(OpenerDirector)。正常情况下我们一直使用默认的opener,通过urlopen,但你也可以创建自定义的openers。
opener使用handler处理任务,所有的重活都交给这些handlers来做。每一个handler知道怎么以特定的url协议打开url,或者怎么处理打开url的某些方面,如,HTTP重定向,或者HTTP cookie。
你可以用build_opener,这是一个很方便的创建opener对象的函数,它只有一个函数调用。
install_opener能设置一个全局opener对象,这意味着调用urlopen将会都用你刚安装的opener。
opener对象有一个open方法,它可以以一种和urlopen函数同样的方式直接调用来获取url:除非是为了方便,没有必要调用install_opener。
OpenerDirector操作类是一个管理很多处理类(Handler)的类。而所有这些 Handler 类都对应处理相应的协议,或者特殊功能。
分别有下面的处理类:BaseHandler,HTTPErrorProcessor,HTTPDefaultErrorHandler,HTTPRedirectHandler,ProxyHandler,AbstractBasicAuthHandler,HTTPBasicAuthHandler,ProxyBasicAuthHandler,AbstractDigestAuthHandler,ProxyDigestAuthHandler,AbstractHTTPHandler,HTTPHandler,HTTPCookieProcessor,UnknownHandler,FileHandler,FTPHandler,CacheFTPHandler。
注:python3中urllib已经整合了urllib,urllib2和urlparse.上述类、方法可以在urllib.request中找到。
转载参考自:http://www.iteedu.com/plang/python/urllib2/opener.php
- python ____opendirector类
- python类
- Python 类
- PYTHON类
- Python类
- python类
- python 类
- Python类
- python 类
- python 类
- Python 类
- python 类
- python类
- Python-类
- Python类
- python 类
- python 类
- python 类
- textarea的value与innerHTML
- android 竖向的progress bar
- Xcode:[__NSCFNumber length]: unrecognized selector sent to instance崩溃解决
- MySQL导出数据库命令
- cocos2dx 3.13.1show_all适配时DEBUG_FPS位置与之前版本不同
- python ____opendirector类
- codeforce Round #379 (Div. 2)C(贪心)
- netstat -tna基本用法
- asp.net 导出到excel
- 关于For of
- 微信公众号开发之接收普通消息
- 最小二乘支持向量机——LSSVM
- 用来截取数据库某一列字段中的一部分 SUBSTR函数
- java中使用mongodb增查改删