Python爬虫学习

Posted hotfeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)

 

以上是关于Python爬虫学习的主要内容,如果未能解决你的问题,请参考以下文章