Hey I'm trying to do something with searching Google using Python, and I found this code that mostly comes up errorless, but I'm getting the error
(TypeError: 'NoneType' object is not subscriptable)
and dont know what to do. Thanks in advance for any help.
import urllib.request
import json as m_json
query = input ( 'Query: ' )
query = urllib.parse.urlencode ( { 'q' : query } )
response = urllib.request.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 )