我有一个搜索主题“leo messi”。我想在过去 2 小时内发布所有关于“leo messi”的博客。现在我被困在这里。这段代码没有过滤博客和时间
import urllib
import json as m_json
query = "leo messi"
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 )