【发布时间】:2018-05-13 22:07:17
【问题描述】:
我想知道是否有办法在我的 Python 程序中将 Google 的搜索结果显示为输出。就像我在程序中输入“Electricity”一样,我想将 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 发布了答案。
标签: python python-2.7 search google-search