Man*_*ram 32
试试这个,它非常简单易用:https: //pypi.python.org/pypi/google
文档:https://breakingcode.wordpress.com/2010/06/29/google-search-python/
Github:https://github.com/MarioVilas/google
安装这个python包,用法就像这样简单:
# Get the first 5 hits for "google 1.9.1 python" in Google Pakistan
from google import search
for url in search('google 1.9.1 python', tld='com.pk', lang='es', stop=5):
print(url)
Run Code Online (Sandbox Code Playgroud)
小智 26
也许,这样的事情?
import urllib
import json as m_json
query = raw_input ( 'Query: ' )
query = urllib.urlencode ( { 'q' : query } )
response = urllib.urlopen ( 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' + query ).read()
json = m_json.loads ( response )
results = json [ 'responseData' ] [ 'results' ]
for result in results:
title = result['title']
url = result['url'] # was URL in the original and that threw a name error exception
print ( title + '; ' + url )
[编辑]由于AJAX API已经死了,你可以使用第三方服务,比如SerpApi,它们确实提供了一个Python库.
| 归档时间: |
|
| 查看次数: |
84966 次 |
| 最近记录: |