python WEB编程常用模块

1.urlparse模块提供操作url字符串的基本功能 urlparse() urlunparse() urljoin()

urlparse(urlstr,defProtSch=None,allow_fragments=True)返回一个6元祖(protsch,netloc,path,param,query,frag)

urlunparse()与上述方法相反

urljoin(baseurl,newurl,allow_fragments=True)

2.urllib模块

urlib提供了一个高级的web交流库,它的特殊功能是利用web协议下载数据

urlib.urlopen(urlstr,postUeryData=None)

urllib.urlretrieve(urlstr,localfile=None,downloadStatusHook=None)下载html到本地文件

3.urlib2模块,能够处理更复杂的url打开问题,如http认证的问题

原文地址:https://www.cnblogs.com/aveenzhou/p/2682637.html