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)

 

posted @ 2017-11-13 15:10  hotfeng  阅读(114)  评论(0编辑  收藏  举报