我正在尝试使用此Python模块来访问Board Game Geek API:
https://github.com/lcosmin/boardgamegeek
在此处找到文档:
https://lcosmin.github.io/boardgamegeek/
有关BGG API本身的更多信息:
http://www.tayloraliss.com/bggapi/index.html
所以我通过pip安装了boardgamegeek2。安装得很好。
然后,我按照文档页面上的演示进行操作:
>>> from boardgamegeek import BGGClient
>>> bgg = BGGClient()
>>> g = bgg.game("Android: Netrunner")
>>> g.name
'Android: Netrunner'
>>> g.id
124742
>>> for n in g.alternative_names: print n.encode("utf-8")
一切正常,直到我进入g = bgg.game(“ Android:Netrunner”)
然后抛出此错误:
Traceback (most recent call last):
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 2878, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-10f1bad2c28e>", line 1, in <module>
g = bgg.game("Android: Netrunner")
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 835, in game
game_id = self.get_game_id(name, choose=choose)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 750, in get_game_id
return self._get_game_id(name, game_type=BGGRestrictSearchResultsTo.BOARD_GAME, choose=choose)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 148, in _get_game_id
res = self.search(name, search_type=[game_type], exact=True)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 685, in search
retry_delay=self._retry_delay)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\utils.py", line 378, in request_and_parse_xml
raise BGGApiError("error fetching BGG API response: {}".format(e))
BGGApiError: error fetching BGG API response: HTTPSConnectionPool(host='www.boardgamegeek.com', port=443): Max retries exceeded with url: /xmlapi2/search?exact=1&query=Android%3A+Netrunner&type=boardgame (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
g = bgg.game("Android: Netrunner")
Traceback (most recent call last):
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 2878, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-10f1bad2c28e>", line 1, in <module>
g = bgg.game("Android: Netrunner")
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 835, in game
game_id = self.get_game_id(name, choose=choose)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 750, in get_game_id
return self._get_game_id(name, game_type=BGGRestrictSearchResultsTo.BOARD_GAME, choose=choose)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 148, in _get_game_id
res = self.search(name, search_type=[game_type], exact=True)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 685, in search
retry_delay=self._retry_delay)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\utils.py", line 378, in request_and_parse_xml
raise BGGApiError("error fetching BGG API response: {}".format(e))
BGGApiError: error fetching BGG API response: HTTPSConnectionPool(host='www.boardgamegeek.com', port=443): Max retries exceeded with url: /xmlapi2/search?exact=1&query=Android%3A+Netrunner&type=boardgame (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
g = bgg.game(124742)
Traceback (most recent call last):
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 2878, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-7d8395392db8>", line 1, in <module>
g = bgg.game(124742)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 835, in game
game_id = self.get_game_id(name, choose=choose)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 750, in get_game_id
return self._get_game_id(name, game_type=BGGRestrictSearchResultsTo.BOARD_GAME, choose=choose)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 148, in _get_game_id
res = self.search(name, search_type=[game_type], exact=True)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\api.py", line 685, in search
retry_delay=self._retry_delay)
File "C:\Users\bnielson\AppData\Local\Continuum\anaconda2\lib\site-packages\boardgamegeek\utils.py", line 378, in request_and_parse_xml
raise BGGApiError("error fetching BGG API response: {}".format(e))
BGGApiError: error fetching BGG API response: HTTPSConnectionPool(host='www.boardgamegeek.com', port=443): Max retries exceeded with url: /xmlapi2/search?exact=1&query=124742&type=boardgame (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
似乎要我先进行身份验证。但是没有提到需要在上面的任何链接上进行此操作,包括官方API文档。发生了什么事?