urllib2 で NYT イベント API を呼び出そうとしていますが、596 エラーが発生します。自分で URL を作成する場合は問題ありませんが、代わりにデータを使用して urlopen を呼び出すと、596 エラーが発生します。どうしたの?596 エラーは文書化されていないようで、役に立ちません。
>>> data = urllib.urlencode({'api-key': os.environ['NYT_EVENT_LISTING_API_KEY']})
>>> resp = urllib2.urlopen('?'.join([url,data]))
>>> resp = urllib2.urlopen(url, data)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 596: