码迷,mamicode.com
首页 > 编程语言 > 详细

Python爬虫学习(一)

时间:2017-11-13 16:45:54      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:cap   网页   baidu   false   ons   utf-8   open   timeout   col   

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爬虫学习(一)

标签:cap   网页   baidu   false   ons   utf-8   open   timeout   col   

原文地址:http://www.cnblogs.com/hotfeng/p/7826446.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!