python库——urllib学习

来源:互联网 发布:js中的splice方法 编辑:程序博客网 时间:2024/06/08 20:09

参考文献:https://docs.python.org/3/library/urllib.html

urllib的学习:

    1.urllib.request:打开或读取url    2.urllib.error:urllib抛出的异常    3.urllib.parse:解析urls    4.urllib.robotparser:解析robots.txt文件

一、urllib.request模块:

    英文概要:The urllib.request module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more.    翻译:urllib.request模块定义了许多函数和类用来帮助在包含基本和摘要认证,缓冲以及更多的复杂情形下打开urls(以http为主)(帮助理解,有翻译不对的地方请与热度原文)

1. urllib.request内部方法:

1.1 urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None)

    @url: 可以是一个request类型的对象,或者字符串    @data: data必须是一个字节对象,指定附加的数据,如果不需要可以为None。    @
0 0
原创粉丝点击