显示谷歌&x27;Python 2.7中的搜索结果

显示谷歌&x27;Python 2.7中的搜索结果,python,python-2.7,search,google-search,Python,Python 2.7,Search,Google Search,我想知道是否有一种方法可以在我的Python程序中将Google的搜索结果显示为输出。比如,如果我在我的程序中输入“电”,那么我想以纯文本的形式显示谷歌的搜索结果。有办法吗 更新 import urllib2 response = urllib2.urlopen("https://en.wikipedia.org/wiki/Machine_learning") the_page = response.read(bytes) content = str(the_page) print the_p

我想知道是否有一种方法可以在我的Python程序中将Google的搜索结果显示为输出。比如,如果我在我的程序中输入“电”,那么我想以纯文本的形式显示谷歌的搜索结果。有办法吗

更新

import urllib2

response = urllib2.urlopen("https://en.wikipedia.org/wiki/Machine_learning")
the_page = response.read(bytes)
content = str(the_page)
print the_page
我尝试了上面的代码,但如果我只是键入,它会显示错误

the_page = response.read()
print the_page

它只打印页面的HTML格式,而不打印文本字符串,因此如何单独获取字符串?

请询问有关代码的问题,而不是一般的编码问题。无论如何,我已经发布了一个答案。@CPanda看看我的更新,请帮助我…@NikhilRaghavendra发布了一个答案。
import urllib2

response = urllib2.urlopen("https://en.wikipedia.org/wiki/Machine_learning")
content= response.read()
# Now it's time for parsing *content* to extract the relevant data
# Use regex, HTMLParser from standard library
# or use beautifulsoup, LXML (third party)