File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 2
2
# SPDX-FileCopyrightText: Copyright (c) 2023 Scott Shawcroft for Adafruit Industries
3
3
#
4
4
# SPDX-License-Identifier: Unlicense
5
+
6
+ import adafruit_requests
7
+ import adafruit_json_stream as json_stream
8
+ import socketpool
9
+ import ssl
10
+ import wifi
11
+ import time
12
+
13
+ pool = socketpool .SocketPool (wifi .radio )
14
+ session = adafruit_requests .Session (pool , ssl .create_default_context ())
15
+
16
+ SCORE_URL = f"http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard"
17
+
18
+ while True :
19
+ resp = session .get (SCORE_URL )
20
+ json_data = json_stream .load (resp .iter_content (32 ))
21
+ for event in json_data ["events" ]:
22
+ if "Seattle" not in event ["name" ]:
23
+ continue
24
+ for competition in event ["competitions" ]:
25
+ for competitor in competition ["competitors" ]:
26
+ print (competitor ["team" ]["displayName" ], competitor ["score" ])
27
+ time .sleep (60 )
You can’t perform that action at this time.
0 commit comments