首页 > 编程语言 > 详细

python 3.x urllib学习

时间:2016-01-18 10:22:08      阅读:247      评论:0      收藏:0      [点我收藏+]

urllib.request

import urllib.request as ur
url=‘http://ie.icoa.cn‘
user_agent = ‘Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)‘
req=ur.Request(url)
req.add_header(‘User-Agent‘,user_agent)
res=ur.urlopen(req)
html=res.read().decode(‘utf8‘)
print(html)

发送一个header,模拟浏览器

 

python 3.x urllib学习

原文:http://www.cnblogs.com/fj0716/p/5138391.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!