您的位置:首页 > 编程语言 > Python开发

Python爬取google搜索结果

2012-07-26 12:28 441 查看
使用Python爬取google的搜索结果:

# -*- coding: utf-8 -*-
import urllib2
import cookielib
url = 'http://www.google.com.hk/search?sourceid=chrome&;ie=UTF-8&q=python'
cj = cookielib.CookieJar()
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent', 'Opera/9.23')]
urllib2.install_opener(opener)
req=urllib2.Request(url)
response =urllib2.urlopen(req)
content = response.read()
print content

参见:/article/2830495.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: