随着Python3的逐渐广泛应用,urllib这个常用的模块自然而然进入了大家的视野,下面主要对Python3.6.0中的urllib模块进行详解,希望能帮到大家
Python3.6.0中urllib模块包括一下四个子模块:
urllib
is a package that collects several modules for working with URLs:
urllib.request
for opening and reading URLsurllib.error
containing the exceptions raised byurllib.request
urllib.parse
for parsing URLsurllib.robotparser
for parsingrobots.txt
files
urllib模块是一个运用于URL的包
urllib.request用于访问和读取URLS
urllib.error包括了所有urllib.request导致的异常
urllib.parse用于解析URLS
urllib.robotparser用于解析robots.txt文件(网络蜘蛛)
下面我将分四部分,对上面四个子模块进行分析:
(一)urllib.request子模块详解
Python3模块详解--老司机工具urllib模块详解之urllib.request子模块
(二)urllib.error子模块
Python3模块详解--老司机工具urllib模块详解之urllib.error子模块
(三)urllib.parse子模块
Python3模块详解--老司机工具urllib模块详解之urllib.parse子模块
(四)urllib.robotparser子模块
This module provides a single class, RobotFileParser
, which answers questions about whether or not a particular user agent can fetch a URL on the Web site that published the robots.txt
file. For more details on the structure of robots.txt
files, see http://www.robotstxt.org/orig.html.
这段话来自于官方API,这块内容我也正在学习中,后期会及时更新上去的,想看细节的同学,可以根据API中提供的链接访问!
如有不足或错误,请及时给我联系,我会在第一时间内更改,谢谢大家!