Reputation: 117
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.
Upvotes: 2
Views: 593
Reputation: 5653
It looks like the Bing Search API changed. Unfortunately, PyBing does not seem to be updated (yet) for the new API, but it should be pretty easy to use the Bing JSON API directly.
Upvotes: 1