您好我正在尝试解析来自matchbook.com api的Feed。我无法发布整个Feed,因为它太长了,但这是我正在使用的代码:
r15 =
s.get('https://api.matchbook.com/edge/rest/events/488126519970009')
r16 = r15.json()
pprint.pprint (r16)
for market_id in r16['markets']:
print (market_id['runners'][0]['market-id'])
for runner in r16['markets']:
print (runner['runners'][0]['name'])
我似乎无法返回超过前2个结果,我不知道为什么?
答案 0 :(得分:1)
代码仅使用第一批参赛者。
迭代所有参赛者:
for market in r16['markets']:
for runner in market['runners']:
print(runner['name'])
打印:
5 Firmament
7 Mitchum Swagger
2 Kool Kompany
1 Jallota
6 Kaspersky
4 Big Baz
3 Beach Bar
1 Jallota
2 Kool Kompany
3 Beach Bar
4 Big Baz
5 Firmament
6 Kaspersky
7 Mitchum Swagger