2016-04-16 20 views
0

Googleの検索結果をPythonプログラムの出力として表示する方法があるかどうかを知りたいと思います。私のプログラムに「Electricity」と入力した場合と同様に、私はGoogleの検索結果をプレーンテキストとして表示したいと考えています。それを行う方法はありますか?Python 2.7でGoogleの検索結果を表示

UPDATE

import urllib2 

response = urllib2.urlopen("https://en.wikipedia.org/wiki/Machine_learning") 
the_page = response.read(bytes) 
content = str(the_page) 
print the_page 

私はちょうどそれは単なるテキストページのHTML形式を印刷しなく

the_page = response.read() 
print the_page 

を入力した場合、私は上記のコードを試してみましたが、それは私にエラーを示していますstringそれでは、どのように文字列を取得するのですか?

+0

https://developers.google.com/custom-search/ – Natecat

+1

一般的なコーディングについてではなく、コードについてご質問ください。とにかく私は答えを掲示しました。 –

+0

@CPanda私の更新を見て、plsは私を助けます.... –

答えて

0
import urllib2 

response = urllib2.urlopen("https://en.wikipedia.org/wiki/Machine_learning") 
content= response.read() 
# now it's time for parsing `cotnent` to extract relevant data 
# Use regex, HTMLParser from standard library 
# or use beautifulsoup, LXML (third party) 
関連する問題