I have written a script to generate the urls using Pybing.
from pybing import Bing
bing = Bing('mykey')
response = bing.search_web('python bing')
print response['SearchResponse']['Web']['Total']
results = response['SearchResponse']['Web']['Results']
print len(results)
for result in results[:3]:
print repr(result['Title'])
The error i get is
Traceback (most recent call last):
File "C:\Python27\Project\YQL.py", line 4, in <module>
print response['SearchResponse']['Web']['Total']
KeyError: 'Web'
On printing response variable i get
{u'SearchResponse': {u'Errors': [{u'HelpUrl': u'http://msdn.microsoft.com/en-
us/library/dd251042.aspx', u'Message': u'Parameter has invalid value.', u'Code': 1002,
u'Parameter': u'SearchRequest.AppId', u'Value': u'mykey'}], u'Query':
{u'SearchTerms': u'pyt'}, u'Version': u'2.0'}}
How should i fix the code.