Python爬虫学习(一)

Python访问网页主要使用包urllib

打开网页使用

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

例子:

import urllib.request
response = urllib.request.urlopen('http://www.baidu.com')
html = response.read()
html = html.decode('utf-8') #对网页进行解码,显示网页源代码
print(html)
原文地址:https://www.cnblogs.com/hotfeng/p/7826446.html