0
새로운 Azure Bing API에서 결과를 얻기 위해 그물에서 다운로드 한 API 래퍼를 사용하려고합니다. 나는 지시에 따라 그것을 구현하려고하지만 런타임 오류 받고 있어요 :Nonetype 객체에 '__getitem__'속성이 없습니다.
import requests
URL = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%(query)s&$top=50&$format=json'
API_KEY = 'SECRET_API_KEY'
def request(query, **params):
r = requests.get(URL % {'query': query}, auth=('', API_KEY))
return r.json['d']['results']
지침은 다음과 같습니다 :
>>> import bingsearch
>>> bingsearch.API_KEY='Your-Api-Key-Here'
>>> r = bingsearch.request("Python Software Foundation")
>>> r.status_code
200
>>> r[0]['Description']
u'Python Software Foundation Home Page. The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to ...'
>>> r[0]['Url']
u'http://www.python.org/psf/
이이
Traceback (most recent call last):
File "bingwrapper.py", line 4, in <module>
bingsearch.request("affirmative action")
File "/usr/local/lib/python2.7/dist-packages/bingsearch-0.1-py2.7.egg/bingsearch.py", line 8, in request
return r.json['d']['results']
TypeError: 'NoneType' object has no attribute '__getitem__'
이 래퍼 코드입니다 래퍼를 사용하는 코드 (지침에 따라) :
import bingsearch
bingsearch.API_KEY='abcdefghijklmnopqrstuv'
r = bingsearch.request("affirmative+action")
오류가 아닌 전체 추적을 제공 할 수 있습니까? –
@isbadawi는 전체 추적을 제공했습니다 – adohertyd
래퍼의 'r'내용은 무엇입니까? –