首页 > 其他 > 详细

爬虫学习

时间:2016-11-04 07:35:48      阅读:284      评论:0      收藏:0      [点我收藏+]
#coding:utf8
__author__ = wang
import urllib2
import cookielib

url = "http://www.baidu.com";

response = urllib2.urlopen(url)
print(len(response.read()));


request = urllib2.Request(url)
request.add_header(user-agent,Mozilla/5.0)
response1 = urllib2.urlopen(request)
print len(response1.read())

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
response2 = urllib2.urlopen(url)
print cj
print len(response2.read())

 

爬虫学习

原文:http://www.cnblogs.com/php-linux/p/6028902.html

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