16.python 爬虫-python如何访问互联网
1.URL格式:protocol://hostname[:port]/path/[;parameters][query]#fragment
三部分组成:
第一部分是protocol即协议:http、https、ftp、file、ed2k...
第二部分是hostname即:域名或者IP地址
第三部分是资源的路径(目录名或者文件名)
2.想要访问网页,需要使用urllib.request下的open函数
格式:
urllib.request.
urlopen
(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None)