import requests
import json
url = "https://betkarma.com/api/propsComparison?startDate=2023-10-17&endDate=2023-10-23&league=nfl"
response = requests.get(url)
data = response.json()
print(response)
for player_name in data["games"][0]["offers"][0]["player"]:
if offers[0] == "player":
value = player["value"]
break
print(player_name)
The above code appears to be correct; however, something certainly is missing in the code below. I’m expecting the first and last name of each participant, but I’m just getting the first letter of the first person’s first name returned for some reason. Any assistance is highly appreciated. I’m not sure whether I’m not outputting the correct thing, if some code is missing, or what I need to do to get a list of names. I’m I’m a noob in python!
>Solution :
try this:
import requests
url = "https://betkarma.com/api/propsComparison?startDate=2023-10-17&endDate=2023-10-23&league=nfl"
response = requests.get(url)
data = response.json()
for p in data.get("games")[0].get("offers"):
print(p["player"])
output:
Foye Oluokun
Foye Oluokun
Michael (Saints) Thomas
Michael (Saints) Thomas
Pete Werner
Pete Werner
Demario Davis
Demario Davis
Marshon Lattimore
Demario Davis
Marshon Lattimore
Pete Werner
Marshon Lattimore
Alontae Taylor
Alontae Taylor
Alontae Taylor
Carl Granderson
Carl Granderson
Carl Granderson
Jaguars DST
Saints DST
Blake Grupe
Brandon McManus
Blake Grupe
Blake Grupe
Brandon McManus
Brandon McManus
Brandon McManus
Blake Grupe
Devin Lloyd
Devin Lloyd
Devin Lloyd
Foyesade Oluokun
Derek Carr
Trevor Lawrence
Trevor Lawrence
Derek Carr
Derek Carr
Derek Carr
Trevor Lawrence
Derek Carr
Trevor Lawrence
Trevor Lawrence
Derek Carr
Derek Carr
Derek Carr
Trevor Lawrence
Derek Carr
Derek Carr
Taysom Hill
Trevor Lawrence
Trevor Lawrence
Alvin Kamara
Travis Etienne Jr.
Travis Etienne Jr.
Travis Etienne Jr.
Alvin Kamara
Tank Bigsby
Alvin Kamara
Alvin Kamara
Travis Etienne Jr.
Travis Etienne Jr.
Alvin Kamara
Travis Etienne Jr.
Travis Etienne Jr.
Alvin Kamara
Alvin Kamara
Travis Etienne Jr.
Alvin Kamara
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Andre Cisco
Andre Cisco
Rayshawn Jenkins
Marcus Maye
Marcus Maye
Rayshawn Jenkins
Rayshawn Jenkins
Andre Cisco
Marcus Maye
Evan Engram
Foster Moreau
Foster Moreau
Foster Moreau
Evan Engram
Evan Engram
Evan Engram
Taysom Hill
Rashid Shaheed
Michael Thomas
Chris Olave
Calvin Ridley
Christian Kirk
Michael Thomas
Chris Olave
Rashid Shaheed
Rashid Shaheed
Calvin Ridley
Christian Kirk
Calvin Ridley
