irongit

An AI project that includes a scraper for NFL data, postgres database, and user interface. It uses a classification algorithm to predict winners.

546 lines37 KB
1{
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "## 1. Set up the scraper\n",
8 "* Download data from nfl.com\n",
9 "* Use internal api with Bearer Key"
10 ]
11 },
12 {
13 "cell_type": "markdown",
14 "metadata": {},
15 "source": [
16 "### 1.1 Get a working example for Bearer token"
17 ]
18 },
19 {
20 "cell_type": "code",
21 "execution_count": 2,
22 "metadata": {},
23 "outputs": [],
24 "source": [
25 "import time\n",
26 "from browsermobproxy import Server\n",
27 "from selenium import webdriver\n",
28 "import json\n",
29 "import os\n",
30 "BMP_PATH = os.path.abspath('browsermob-proxy-2.1.4/bin/browsermob-proxy.bat')\n",
31 "\n",
32 "# Start BrowserMob Proxy\n",
33 "server = Server(BMP_PATH)\n",
34 "server.start()\n",
35 "proxy = server.create_proxy()\n",
36 "\n",
37 "# Configure Chrome with the proxy\n",
38 "chrome_options = webdriver.ChromeOptions()\n",
39 "chrome_options.add_argument(f'--proxy-server={proxy.proxy}')\n",
40 "chrome_options.add_argument('--ignore-certificate-errors')\n",
41 "chrome_options.add_argument('--headless')\n",
42 "driver = webdriver.Chrome(options=chrome_options)\n",
43 "# Navigate to the website\n",
44 "driver.get(\"https://nfl.com/scores\")\n",
45 "\n",
46 "# Start capturing network traffic\n",
47 "proxy.new_har(\"nfl\", options={'captureHeaders': True})\n",
48 "\n",
49 "# Wait for the header with the name \"Authorization\"\n",
50 "timeout = 60 # Adjust the timeout as needed\n",
51 "def get_auth_token():\n",
52 " start_time = time.time()\n",
53 " while time.time() - start_time < timeout:\n",
54 " har = proxy.har\n",
55 " for entry in har['log']['entries']:\n",
56 " request_headers = entry['request']['headers']\n",
57 " for header in request_headers:\n",
58 " if header['name'] == 'Authorization':\n",
59 " return header['value']\n",
60 " time.sleep(1)\n",
61 " return None\n",
62 "auth_token = get_auth_token()\n",
63 "\n",
64 "# Store the auth token\n",
65 "auth_path = 'auth.json'\n",
66 "auth_json = {\n",
67 " 'time': time.time(),\n",
68 " 'token': auth_token\n",
69 "}\n",
70 "with open(auth_path, 'w') as f:\n",
71 " json.dump(auth_json, f)\n",
72 "\n",
73 "# Stop capturing network traffic\n",
74 "har = proxy.har\n",
75 "\n",
76 "# Close the browser and BrowserMob Proxy\n",
77 "driver.quit()\n",
78 "server.stop()"
79 ]
80 },
81 {
82 "cell_type": "markdown",
83 "metadata": {},
84 "source": [
85 "### 1.2 Create a class that manages requests to nfl.com"
86 ]
87 },
88 {
89 "cell_type": "code",
90 "execution_count": 1,
91 "metadata": {},
92 "outputs": [],
93 "source": [
94 "from nfl_client import NFLClient\n",
95 "client = NFLClient()"
96 ]
97 },
98 {
99 "cell_type": "code",
100 "execution_count": 2,
101 "metadata": {},
102 "outputs": [
103 {
104 "name": "stdout",
105 "output_type": "stream",
106 "text": [
107 "Auth Token: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6ImU1MzVjN2MwLTgxN2YtNDc3Ni04OTkwLTU2NTU2ZjhiMTkyOCIsImNsaWVudEtleSI6IjRjRlVXNkRtd0pwelQ5TDdMckczcVJBY0FCRzVzMDRnIiwiaXNzIjoiTkZMIiwiZGV2aWNlSWQiOiJkMTdlYThlYy02NWVlLTQ5YjUtOTYyNi04NThjN2I4NDFjNDUiLCJwbGFucyI6W3sicGxhbiI6ImZyZWUiLCJleHBpcmF0aW9uRGF0ZSI6IjIwMjQtMTEtMDQiLCJzb3VyY2UiOiJORkwiLCJzdGFydERhdGUiOiIyMDIzLTExLTA1Iiwic3RhdHVzIjoiQUNUSVZFIiwidHJpYWwiOmZhbHNlfV0sIkRpc3BsYXlOYW1lIjoiV0VCX0RFU0tUT1BfREVTS1RPUCIsIk5vdGVzIjoiIiwiZm9ybUZhY3RvciI6IkRFU0tUT1AiLCJsdXJhQXBwS2V5IjoiU1pzNTdkQkdSeGJMNzI4bFZwN0RZUSIsInBsYXRmb3JtIjoiREVTS1RPUCIsInByb2R1Y3ROYW1lIjoiV0VCIiwiY2l0eSI6ImFwcGxlIHZhbGxleSIsImNvdW50cnlDb2RlIjoiVVMiLCJkbWFDb2RlIjoiODAzIiwiaG1hVGVhbXMiOlsiMTA0MDI1MTAtODkzMS0wZDVmLTk4MTUtNzliYjc5NjQ5YTY1IiwiMTA0MDI1MjAtOTZiZi1lOWYyLTRmNjgtODUyMWNhODk2MDYwIiwiMTA0MDQ0MDAtM2IzNS0wNzNmLTE5N2UtMTk0YmI4MjQwNzIzIl0sInJlZ2lvbiI6IkNBIiwiYnJvd3NlciI6IkNocm9tZSBIZWFkbGVzcyIsImNlbGx1bGFyIjpmYWxzZSwiZW52aXJvbm1lbnQiOiJwcm9kdWN0aW9uIiwicm9sZXMiOlsiZnJlZSJdLCJleHAiOjE2OTkxNTkxNTN9.uq3VzAFHpGdUzkvWvYcWzykY6NBlCmuYUR-bR-y_-iQ\n"
108 ]
109 }
110 ],
111 "source": [
112 "client.load_auth_token()\n",
113 "print('Auth Token:', client.auth_token)"
114 ]
115 },
116 {
117 "cell_type": "code",
118 "execution_count": 3,
119 "metadata": {},
120 "outputs": [
121 {
122 "name": "stdout",
123 "output_type": "stream",
124 "text": [
125 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
126 "https://api.nfl.com/football/v2/games/b07eb396-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
127 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
128 "https://api.nfl.com/football/v2/games/b07eccd5-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
129 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
130 "https://api.nfl.com/football/v2/games/b07eaef2-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
131 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaef2-f053-11ed-b4a7-bab79e4492fa\n",
132 "https://api.nfl.com/football/v2/games/b07eaef2-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
133 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaef2-f053-11ed-b4a7-bab79e4492fa\n",
134 "https://api.nfl.com/football/v2/games/b07eb396-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
135 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
136 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
137 "https://api.nfl.com/football/v2/games/b07eb396-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
138 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
139 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
140 "https://api.nfl.com/football/v2/games/b07eb9ec-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
141 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
142 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
143 "https://api.nfl.com/football/v2/games/b07eb9ec-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
144 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
145 "https://api.nfl.com/football/v2/games/b07ebf16-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
146 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
147 "https://api.nfl.com/football/v2/games/b07ebf16-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
148 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
149 "https://api.nfl.com/football/v2/games/b07ec38f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
150 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
151 "https://api.nfl.com/football/v2/games/b07ec38f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
152 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
153 "https://api.nfl.com/football/v2/games/b07ec866-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
154 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
155 "https://api.nfl.com/football/v2/games/b07ec866-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
156 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
157 "https://api.nfl.com/football/v2/games/b07eccd5-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
158 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
159 "https://api.nfl.com/football/v2/games/b07eccd5-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
160 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
161 "https://api.nfl.com/football/v2/games/b07ed134-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
162 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
163 "https://api.nfl.com/football/v2/games/b07ed134-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
164 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
165 "https://api.nfl.com/football/v2/games/b07ed134-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
166 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
167 "https://api.nfl.com/football/v2/games/b07ed7da-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
168 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
169 "https://api.nfl.com/football/v2/games/b07edc7f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
170 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
171 "https://api.nfl.com/football/v2/games/b07ed7da-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
172 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
173 "https://api.nfl.com/football/v2/games/b07ed7da-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
174 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
175 "https://api.nfl.com/football/v2/games/b07edc7f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
176 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
177 "https://api.nfl.com/football/v2/games/b07edc7f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
178 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
179 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
180 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
181 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
182 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
183 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
184 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
185 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
186 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
187 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
188 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
189 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
190 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
191 "https://api.nfl.com/content/v1/videos/replays?gameId=b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
192 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
193 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ee5cd-f053-11ed-b4a7-bab79e4492fa\n",
194 "https://api.nfl.com/football/v2/games/b07eaa67-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
195 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaa67-f053-11ed-b4a7-bab79e4492fa\n",
196 "https://api.nfl.com/football/v2/games/b07eaef2-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
197 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
198 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaef2-f053-11ed-b4a7-bab79e4492fa\n",
199 "https://api.nfl.com/football/v2/games/b07eb9ec-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
200 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
201 "https://api.nfl.com/football/v2/games/b07ebf16-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
202 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
203 "https://api.nfl.com/football/v2/games/b07ec38f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
204 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
205 "https://api.nfl.com/football/v2/games/b07eb396-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
206 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
207 "https://api.nfl.com/football/v2/games/b07eccd5-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
208 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
209 "https://api.nfl.com/football/v2/games/b07ec866-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
210 "https://api.nfl.com/football/v2/games/b07ed134-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
211 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
212 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
213 "https://api.nfl.com/football/v2/games/b07ed7da-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
214 "https://api.nfl.com/football/v2/games/b07edc7f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
215 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
216 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
217 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
218 "https://api.nfl.com/live/v1/livestreams?contentType=GAME&endTime=2023-11-07T08%3A00%3A00.000Z&startTime=2023-11-01T07%3A00%3A00.000Z\n",
219 "https://api.nfl.com/live/v1/livestreams?contentType=GAME&endTime=2023-11-05T07%3A00%3A00.000Z&startTime=2023-11-03T07%3A00%3A00.000Z\n",
220 "https://api.nfl.com/live/v1/livestreams?contentType=AUDIO&endTime=2023-11-07T08%3A00%3A00.000Z&startTime=2023-11-01T07%3A00%3A00.000Z\n",
221 "https://api.nfl.com/live/v1/livestreams?contentType=AUDIO&endTime=2023-11-05T07%3A00%3A00.000Z&startTime=2023-11-03T07%3A00%3A00.000Z\n",
222 "https://api.nfl.com/football/v2/games/b07eaa67-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
223 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
224 "https://api.nfl.com/football/v2/games/b07eb9ec-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
225 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaa67-f053-11ed-b4a7-bab79e4492fa\n",
226 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaef2-f053-11ed-b4a7-bab79e4492fa\n",
227 "https://api.nfl.com/football/v2/games/b07eaef2-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
228 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
229 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
230 "https://api.nfl.com/football/v2/games/b07ebf16-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
231 "https://api.nfl.com/football/v2/games/b07ec38f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
232 "https://api.nfl.com/football/v2/games/b07eb396-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
233 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
234 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
235 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
236 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
237 "https://api.nfl.com/football/v2/games/b07eccd5-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
238 "https://api.nfl.com/football/v2/games/b07ed134-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
239 "https://api.nfl.com/football/v2/games/b07ec866-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
240 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
241 "https://api.nfl.com/football/v2/games/b07ed7da-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
242 "https://api.nfl.com/football/v2/games/b07edc7f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
243 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
244 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
245 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
246 "https://api.nfl.com/live/v1/livestreams?contentType=AUDIO&endTime=2023-11-05T07%3A00%3A00.000Z&startTime=2023-11-03T07%3A00%3A00.000Z\n",
247 "https://api.nfl.com/live/v1/livestreams?contentType=GAME&endTime=2023-11-07T08%3A00%3A00.000Z&startTime=2023-11-01T07%3A00%3A00.000Z\n",
248 "https://api.nfl.com/live/v1/livestreams?contentType=GAME&endTime=2023-11-05T07%3A00%3A00.000Z&startTime=2023-11-03T07%3A00%3A00.000Z\n",
249 "https://api.nfl.com/live/v1/livestreams?contentType=AUDIO&endTime=2023-11-07T08%3A00%3A00.000Z&startTime=2023-11-01T07%3A00%3A00.000Z\n",
250 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
251 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eaef2-f053-11ed-b4a7-bab79e4492fa\n",
252 "https://api.nfl.com/football/v2/games/b07eaef2-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
253 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
254 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
255 "https://api.nfl.com/football/v2/games/b07ebf16-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
256 "https://api.nfl.com/football/v2/games/b07eb9ec-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
257 "https://api.nfl.com/football/v2/games/b07ec38f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
258 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
259 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
260 "https://api.nfl.com/football/v2/games/b07eb396-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
261 "https://api.nfl.com/football/v2/games/b07ec866-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
262 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
263 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
264 "https://api.nfl.com/football/v2/games/b07ed134-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
265 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
266 "https://api.nfl.com/football/v2/games/b07eccd5-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
267 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
268 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
269 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
270 "https://api.nfl.com/football/v2/games/b07ed7da-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
271 "https://api.nfl.com/football/v2/games/b07edc7f-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
272 "https://api.nfl.com/content/v1/videos?clipType=Preview&season=2023&seasonType=REG&week=9&sort=contentDate%3Adesc\n",
273 "https://api.nfl.com/football/v2/stats/live/game-summaries/b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
274 "https://api.nfl.com/football/v2/games/b07ee104-f053-11ed-b4a7-bab79e4492fa?withExternalIds=true\n",
275 "https://api.nfl.com/content/v1/videos?clipType=Preview&season=2023&seasonType=REG&week=9&sort=contentDate%3Adesc\n",
276 "https://api.nfl.com/football/v2/games/season/2023/seasonType/REG/week/10?withExternalIds=true\n",
277 "https://api.nfl.com/football/v2/games/season/2023/seasonType/REG/week/10?withExternalIds=true\n",
278 "https://api.nfl.com/football/v2/standings?seasonType=REG&week=8&season=2023&limit=100\n",
279 "https://api.nfl.com/football/v2/standings?seasonType=REG&week=8&season=2023&limit=100\n",
280 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eaa67-f053-11ed-b4a7-bab79e4492fa\n",
281 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eaef2-f053-11ed-b4a7-bab79e4492fa\n",
282 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eb396-f053-11ed-b4a7-bab79e4492fa\n",
283 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eb9ec-f053-11ed-b4a7-bab79e4492fa\n",
284 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ebf16-f053-11ed-b4a7-bab79e4492fa\n",
285 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ec38f-f053-11ed-b4a7-bab79e4492fa\n",
286 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ec866-f053-11ed-b4a7-bab79e4492fa\n",
287 "https://api.nfl.com/content/v1/videos/replays?gameId=b07eccd5-f053-11ed-b4a7-bab79e4492fa\n",
288 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ed134-f053-11ed-b4a7-bab79e4492fa\n",
289 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ed7da-f053-11ed-b4a7-bab79e4492fa\n",
290 "https://api.nfl.com/content/v1/videos/replays?gameId=b07edc7f-f053-11ed-b4a7-bab79e4492fa\n",
291 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ee104-f053-11ed-b4a7-bab79e4492fa\n",
292 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ee5cd-f053-11ed-b4a7-bab79e4492fa\n",
293 "https://api.nfl.com/content/v1/videos/replays?gameId=b07ea540-f053-11ed-b4a7-bab79e4492fa\n",
294 "https://api.nfl.com/fe-store/instances?query=query%7Bviewer%7Binstances(ids%3A%5B%22a2d4a910-4a59-447b-abde-dd969693e784%22%5D%2Clabel%3A%22%22)%7Bedges%7Bnode%7BbuyTicketsDefault%7Btext%2Curl%7D%2CbuyTicketsProBowl%7Btext%2Curl%7D%2CbuyTicketsSuperBowl%7Btext%2Curl%7D%2CrewatchCTA%7Btext%2Curl%7D%7D%7D%7D%7D%7D&variables=%7B%22FE_STORE_INSTANCE_NAMESPACE%22%3A%22WEB.NDC%22%2C%22FE_STORE_TYPE_NAME%22%3A%22ScoresPage%22%2C%22FE_STORE_TYPE_NAMESPACE%22%3A%22WEB%22%7D\n",
295 "https://api.nfl.com/fe-store/instances?query=query%7Bviewer%7Binstances(ids%3A%5B%2248ca44cb-212e-4dfd-a277-1d40f26b0ed1%22%5D%2Clabel%3A%22%22)%7Bedges%7Bnode%7Bname%2Citems%7Bid%2Cname%2Cimage%7Bid%2Csrc%2Cname%2Calt%7D%2Clinks%7Bid%2Curl%2Cname%2Ctext%7D%2Csummary%2Ctitle%2Ccategory%7D%2Ctitle%2Ctype%7D%7D%7D%7D%7D&variables=%7B%22FE_STORE_INSTANCE_NAMESPACE%22%3A%22WEB.NDC%22%2C%22FE_STORE_TYPE_NAME%22%3A%22CardList%22%2C%22FE_STORE_TYPE_NAMESPACE%22%3A%22WEB%22%7D\n",
296 "https://api.nfl.com/fe-store/instances?query=query%7Bviewer%7Binstances(ids%3A%5B%22a2d4a910-4a59-447b-abde-dd969693e784%22%5D%2Clabel%3A%22%22)%7Bedges%7Bnode%7BbuyTicketsDefault%7Btext%2Curl%7D%2CbuyTicketsProBowl%7Btext%2Curl%7D%2CbuyTicketsSuperBowl%7Btext%2Curl%7D%2CrewatchCTA%7Btext%2Curl%7D%7D%7D%7D%7D%7D&variables=%7B%22FE_STORE_INSTANCE_NAMESPACE%22%3A%22WEB.NDC%22%2C%22FE_STORE_TYPE_NAME%22%3A%22ScoresPage%22%2C%22FE_STORE_TYPE_NAMESPACE%22%3A%22WEB%22%7D\n",
297 "https://api.nfl.com/fe-store/instances?query=query%7Bviewer%7Binstances(ids%3A%5B%2248ca44cb-212e-4dfd-a277-1d40f26b0ed1%22%5D%2Clabel%3A%22%22)%7Bedges%7Bnode%7Bname%2Citems%7Bid%2Cname%2Cimage%7Bid%2Csrc%2Cname%2Calt%7D%2Clinks%7Bid%2Curl%2Cname%2Ctext%7D%2Csummary%2Ctitle%2Ccategory%7D%2Ctitle%2Ctype%7D%7D%7D%7D%7D&variables=%7B%22FE_STORE_INSTANCE_NAMESPACE%22%3A%22WEB.NDC%22%2C%22FE_STORE_TYPE_NAME%22%3A%22CardList%22%2C%22FE_STORE_TYPE_NAMESPACE%22%3A%22WEB%22%7D\n",
298 "https://api.nfl.com/play/v1/asset/L5P64hq7cI6KLFiWM_XVSA\n",
299 "https://api.nfl.com/play/v1/asset/L5P64hq7cI6KLFiWM_XVSA\n"
300 ]
301 }
302 ],
303 "source": [
304 "client.download_endpoints()"
305 ]
306 },
307 {
308 "cell_type": "code",
309 "execution_count": 25,
310 "metadata": {},
311 "outputs": [
312 {
313 "data": {
314 "text/plain": [
315 "WindowsPath('nfl_client_data/har_files')"
316 ]
317 },
318 "execution_count": 25,
319 "metadata": {},
320 "output_type": "execute_result"
321 }
322 ],
323 "source": [
324 "client.HAR_DIR"
325 ]
326 },
327 {
328 "cell_type": "code",
329 "execution_count": 103,
330 "metadata": {},
331 "outputs": [
332 {
333 "data": {
334 "text/plain": [
335 "'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6ImU1MzVjN2MwLTgxN2YtNDc3Ni04OTkwLTU2NTU2ZjhiMTkyOCIsImNsaWVudEtleSI6IjRjRlVXNkRtd0pwelQ5TDdMckczcVJBY0FCRzVzMDRnIiwiaXNzIjoiTkZMIiwiZGV2aWNlSWQiOiI3ZWRmZDk4Yy03MDY0LTQyMTUtYjFiMi0yOTY4MGFhODgyNzgiLCJwbGFucyI6W3sicGxhbiI6ImZyZWUiLCJleHBpcmF0aW9uRGF0ZSI6IjIwMjQtMTEtMDQiLCJzb3VyY2UiOiJORkwiLCJzdGFydERhdGUiOiIyMDIzLTExLTA0Iiwic3RhdHVzIjoiQUNUSVZFIiwidHJpYWwiOmZhbHNlfV0sIkRpc3BsYXlOYW1lIjoiV0VCX0RFU0tUT1BfREVTS1RPUCIsIk5vdGVzIjoiIiwiZm9ybUZhY3RvciI6IkRFU0tUT1AiLCJsdXJhQXBwS2V5IjoiU1pzNTdkQkdSeGJMNzI4bFZwN0RZUSIsInBsYXRmb3JtIjoiREVTS1RPUCIsInByb2R1Y3ROYW1lIjoiV0VCIiwiY2l0eSI6ImFwcGxlIHZhbGxleSIsImNvdW50cnlDb2RlIjoiVVMiLCJkbWFDb2RlIjoiODAzIiwiaG1hVGVhbXMiOlsiMTA0MDI1MTAtODkzMS0wZDVmLTk4MTUtNzliYjc5NjQ5YTY1IiwiMTA0MDI1MjAtOTZiZi1lOWYyLTRmNjgtODUyMWNhODk2MDYwIiwiMTA0MDQ0MDAtM2IzNS0wNzNmLTE5N2UtMTk0YmI4MjQwNzIzIl0sInJlZ2lvbiI6IkNBIiwiYnJvd3NlciI6IkNocm9tZSIsImNlbGx1bGFyIjpmYWxzZSwiZW52aXJvbm1lbnQiOiJwcm9kdWN0aW9uIiwicm9sZXMiOlsiZnJlZSJdLCJleHAiOjE2OTkxNDA3OTB9.L9qs6t9J4yU89RO4Jq1u3YUEIxsmxQ4ffZeXzmHlGn0'"
336 ]
337 },
338 "execution_count": 103,
339 "metadata": {},
340 "output_type": "execute_result"
341 }
342 ],
343 "source": [
344 "import json\n",
345 "\n",
346 "\n",
347 "def get_token():\n",
348 " with open('nfl.har', 'r') as f:\n",
349 " har_json = json.load(f)\n",
350 " for entry in har_json['log']['entries']:\n",
351 " for header in entry['request']['headers']:\n",
352 " if header['name'].lower() == 'authorization':\n",
353 " return header['value']\n",
354 "get_token()\n"
355 ]
356 },
357 {
358 "cell_type": "code",
359 "execution_count": 93,
360 "metadata": {},
361 "outputs": [
362 {
363 "name": "stdout",
364 "output_type": "stream",
365 "text": [
366 "Authorization header found in the HAR\n"
367 ]
368 }
369 ],
370 "source": [
371 "from browsermobproxy import Server\n",
372 "from selenium import webdriver\n",
373 "from selenium.webdriver.common.by import By\n",
374 "from selenium.webdriver.support.ui import WebDriverWait\n",
375 "from selenium.webdriver.support import expected_conditions as EC\n",
376 "\n",
377 "# Start BrowserMob Proxy\n",
378 "server = Server(BMP_PATH)\n",
379 "server.start()\n",
380 "proxy = server.create_proxy()\n",
381 "\n",
382 "# Configure Chrome with the proxy\n",
383 "chrome_options = webdriver.ChromeOptions()\n",
384 "chrome_options.add_argument(f'--proxy-server={proxy.proxy}')\n",
385 "chrome_options.add_argument('--ignore-certificate-errors')\n",
386 "driver = webdriver.Chrome(options=chrome_options)\n",
387 "\n",
388 "# Navigate to the website\n",
389 "driver.get(\"https://nfl.com\")\n",
390 "\n",
391 "# Start capturing network traffic\n",
392 "proxy.new_har(\"nfl\", options={'captureHeaders': True})\n",
393 "\n",
394 "# Perform interactions on the website as needed\n",
395 "\n",
396 "# Wait for the \"Authorization\" header to appear in the HAR\n",
397 "def is_authorization_in_har(har):\n",
398 " for entry in har['log']['entries']:\n",
399 " for header in entry['request']['headers']:\n",
400 " if header['name'] == 'Authorization':\n",
401 " return True\n",
402 " return False\n",
403 "\n",
404 "wait = WebDriverWait(driver, 60) # Adjust the timeout as needed\n",
405 "try:\n",
406 " wait.until(lambda driver: is_authorization_in_har(proxy.har))\n",
407 " print(\"Authorization header found in the HAR\")\n",
408 "except Exception:\n",
409 " print(\"Authorization header not found in the HAR\")\n",
410 "\n",
411 "# Close the browser and BrowserMob Proxy\n",
412 "driver.quit()\n",
413 "server.stop()\n"
414 ]
415 },
416 {
417 "cell_type": "code",
418 "execution_count": 38,
419 "metadata": {},
420 "outputs": [],
421 "source": [
422 "from selenium import webdriver\n",
423 "\n",
424 "\n",
425 "options = webdriver.ChromeOptions()\n",
426 "options.add_argument('--headless')\n",
427 "\n",
428 "driver = webdriver.Chrome(options)\n",
429 "\n",
430 "root_url = 'https://google.com'\n",
431 "root_url = 'https://nfl.com'\n",
432 "driver.get(root_url)"
433 ]
434 },
435 {
436 "cell_type": "code",
437 "execution_count": 48,
438 "metadata": {},
439 "outputs": [
440 {
441 "ename": "WebDriverException",
442 "evalue": "Message: unknown error: network conditions must be set before it can be retrieved\n (Session info: headless chrome=118.0.5993.120)\nStacktrace:\n\tGetHandleVerifier [0x00007FF7D1028EF2+54786]\n\t(No symbol) [0x00007FF7D0F95612]\n\t(No symbol) [0x00007FF7D0E4A64B]\n\t(No symbol) [0x00007FF7D0EB8E10]\n\t(No symbol) [0x00007FF7D0EABE30]\n\t(No symbol) [0x00007FF7D0E80941]\n\t(No symbol) [0x00007FF7D0E81B84]\n\tGetHandleVerifier [0x00007FF7D1377F52+3524194]\n\tGetHandleVerifier [0x00007FF7D13CD800+3874576]\n\tGetHandleVerifier [0x00007FF7D13C5D7F+3843215]\n\tGetHandleVerifier [0x00007FF7D10C5086+694166]\n\t(No symbol) [0x00007FF7D0FA0A88]\n\t(No symbol) [0x00007FF7D0F9CA94]\n\t(No symbol) [0x00007FF7D0F9CBC2]\n\t(No symbol) [0x00007FF7D0F8CC83]\n\tBaseThreadInitThunk [0x00007FFD49F27344+20]\n\tRtlUserThreadStart [0x00007FFD4A5E26B1+33]\n",
443 "output_type": "error",
444 "traceback": [
445 "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
446 "\u001b[1;31mWebDriverException\u001b[0m Traceback (most recent call last)",
447 "\u001b[1;32mc:\\Users\\huncho\\code\\hackathons\\DockerAiHackathon\\main.ipynb Cell 4\u001b[0m line \u001b[0;36m1\n\u001b[1;32m----> <a href='vscode-notebook-cell:/c%3A/Users/huncho/code/hackathons/DockerAiHackathon/main.ipynb#X11sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m driver\u001b[39m.\u001b[39;49mget_network_conditions()\n",
448 "File \u001b[1;32mc:\\Users\\huncho\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\selenium\\webdriver\\chromium\\webdriver.py:82\u001b[0m, in \u001b[0;36mChromiumDriver.get_network_conditions\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 75\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mget_network_conditions\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[0;32m 76\u001b[0m \u001b[39m\"\"\"Gets Chromium network emulation settings.\u001b[39;00m\n\u001b[0;32m 77\u001b[0m \n\u001b[0;32m 78\u001b[0m \u001b[39m :Returns: A dict. For example: {'latency': 4,\u001b[39;00m\n\u001b[0;32m 79\u001b[0m \u001b[39m 'download_throughput': 2, 'upload_throughput': 2, 'offline':\u001b[39;00m\n\u001b[0;32m 80\u001b[0m \u001b[39m False}\u001b[39;00m\n\u001b[0;32m 81\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[1;32m---> 82\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mexecute(\u001b[39m\"\u001b[39;49m\u001b[39mgetNetworkConditions\u001b[39;49m\u001b[39m\"\u001b[39;49m)[\u001b[39m\"\u001b[39m\u001b[39mvalue\u001b[39m\u001b[39m\"\u001b[39m]\n",
449 "File \u001b[1;32mc:\\Users\\huncho\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py:347\u001b[0m, in \u001b[0;36mWebDriver.execute\u001b[1;34m(self, driver_command, params)\u001b[0m\n\u001b[0;32m 345\u001b[0m response \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcommand_executor\u001b[39m.\u001b[39mexecute(driver_command, params)\n\u001b[0;32m 346\u001b[0m \u001b[39mif\u001b[39;00m response:\n\u001b[1;32m--> 347\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49merror_handler\u001b[39m.\u001b[39;49mcheck_response(response)\n\u001b[0;32m 348\u001b[0m response[\u001b[39m\"\u001b[39m\u001b[39mvalue\u001b[39m\u001b[39m\"\u001b[39m] \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_unwrap_value(response\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mvalue\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m))\n\u001b[0;32m 349\u001b[0m \u001b[39mreturn\u001b[39;00m response\n",
450 "File \u001b[1;32mc:\\Users\\huncho\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:229\u001b[0m, in \u001b[0;36mErrorHandler.check_response\u001b[1;34m(self, response)\u001b[0m\n\u001b[0;32m 227\u001b[0m alert_text \u001b[39m=\u001b[39m value[\u001b[39m\"\u001b[39m\u001b[39malert\u001b[39m\u001b[39m\"\u001b[39m]\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mtext\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 228\u001b[0m \u001b[39mraise\u001b[39;00m exception_class(message, screen, stacktrace, alert_text) \u001b[39m# type: ignore[call-arg] # mypy is not smart enough here\u001b[39;00m\n\u001b[1;32m--> 229\u001b[0m \u001b[39mraise\u001b[39;00m exception_class(message, screen, stacktrace)\n",
451 "\u001b[1;31mWebDriverException\u001b[0m: Message: unknown error: network conditions must be set before it can be retrieved\n (Session info: headless chrome=118.0.5993.120)\nStacktrace:\n\tGetHandleVerifier [0x00007FF7D1028EF2+54786]\n\t(No symbol) [0x00007FF7D0F95612]\n\t(No symbol) [0x00007FF7D0E4A64B]\n\t(No symbol) [0x00007FF7D0EB8E10]\n\t(No symbol) [0x00007FF7D0EABE30]\n\t(No symbol) [0x00007FF7D0E80941]\n\t(No symbol) [0x00007FF7D0E81B84]\n\tGetHandleVerifier [0x00007FF7D1377F52+3524194]\n\tGetHandleVerifier [0x00007FF7D13CD800+3874576]\n\tGetHandleVerifier [0x00007FF7D13C5D7F+3843215]\n\tGetHandleVerifier [0x00007FF7D10C5086+694166]\n\t(No symbol) [0x00007FF7D0FA0A88]\n\t(No symbol) [0x00007FF7D0F9CA94]\n\t(No symbol) [0x00007FF7D0F9CBC2]\n\t(No symbol) [0x00007FF7D0F8CC83]\n\tBaseThreadInitThunk [0x00007FFD49F27344+20]\n\tRtlUserThreadStart [0x00007FFD4A5E26B1+33]\n"
452 ]
453 }
454 ],
455 "source": [
456 "driver.get_network_conditions()"
457 ]
458 },
459 {
460 "cell_type": "code",
461 "execution_count": 50,
462 "metadata": {},
463 "outputs": [],
464 "source": [
465 "driver.quit()"
466 ]
467 },
468 {
469 "cell_type": "code",
470 "execution_count": 34,
471 "metadata": {},
472 "outputs": [],
473 "source": [
474 "import requests\n",
475 "import json\n",
476 "\n",
477 "# Define the access token\n",
478 "access_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6ImU1MzVjN2MwLTgxN2YtNDc3Ni04OTkwLTU2NTU2ZjhiMTkyOCIsImNsaWVudEtleSI6IjRjRlVXNkRtd0pwelQ5TDdMckczcVJBY0FCRzVzMDRnIiwiaXNzIjoiTkZMIiwiZGV2aWNlSWQiOiI5NTIzOGE1YS05MTIxLTQzNTEtOTY4MC0wNzZlN2Y2ZTQ1NmYiLCJwbGFucyI6W3sicGxhbiI6ImZyZWUiLCJleHBpcmF0aW9uRGF0ZSI6IjIwMjQtMTEtMDMiLCJzb3VyY2UiOiJORkwiLCJzdGFydERhdGUiOiIyMDIzLTExLTA0Iiwic3RhdHVzIjoiQUNUSVZFIiwidHJpYWwiOmZhbHNlfV0sIkRpc3BsYXlOYW1lIjoiV0VCX0RFU0tUT1BfREVTS1RPUCIsIk5vdGVzIjoiIiwiZm9ybUZhY3RvciI6IkRFU0tUT1AiLCJsdXJhQXBwS2V5IjoiU1pzNTdkQkdSeGJMNzI4bFZwN0RZUSIsInBsYXRmb3JtIjoiREVTS1RPUCIsInByb2R1Y3ROYW1lIjoiV0VCIiwiY2l0eSI6ImxvcyBhbmdlbGVzIiwiY291bnRyeUNvZGUiOiJVUyIsImRtYUNvZGUiOiI4MDMiLCJobWFUZWFtcyI6WyIxMDQwMjUxMC04OTMxLTBkNWYtOTgxNS03OWJiNzk2NDlhNjUiLCIxMDQwMjUyMC05NmJmLWU5ZjItNGY2OC04NTIxY2E4OTYwNjAiLCIxMDQwNDQwMC0zYjM1LTA3M2YtMTk3ZS0xOTRiYjgyNDA3MjMiXSwicmVnaW9uIjoiQ0EiLCJicm93c2VyIjoiQ2hyb21lIiwiY2VsbHVsYXIiOmZhbHNlLCJlbnZpcm9ubWVudCI6InByb2R1Y3Rpb24iLCJyb2xlcyI6WyJmcmVlIl0sImV4cCI6MTY5OTA2NTUwMH0.3a0m-SwXS5ElV9NHNFy2EXwTUDtDCzZkpdPpYs-eW_g'\n",
479 "headers = {\n",
480 " 'Authorization': access_token\n",
481 "}\n",
482 "\n",
483 "def request(api_url):\n",
484 " return requests.get(api_url, headers={\n",
485 " 'Authorization': access_token\n",
486 " })"
487 ]
488 },
489 {
490 "cell_type": "markdown",
491 "metadata": {},
492 "source": [
493 "### 1.2 Get team data through the teams endpoint"
494 ]
495 },
496 {
497 "cell_type": "code",
498 "execution_count": 35,
499 "metadata": {},
500 "outputs": [
501 {
502 "data": {
503 "text/plain": [
504 "<Response [200]>"
505 ]
506 },
507 "execution_count": 35,
508 "metadata": {},
509 "output_type": "execute_result"
510 }
511 ],
512 "source": [
513 "api_url = 'https://api.nfl.com/football/v2/teams?limit=100&season=2023'\n",
514 "request(api_url)"
515 ]
516 },
517 {
518 "cell_type": "code",
519 "execution_count": null,
520 "metadata": {},
521 "outputs": [],
522 "source": []
523 }
524 ],
525 "metadata": {
526 "kernelspec": {
527 "display_name": "Python 3",
528 "language": "python",
529 "name": "python3"
530 },
531 "language_info": {
532 "codemirror_mode": {
533 "name": "ipython",
534 "version": 3
535 },
536 "file_extension": ".py",
537 "mimetype": "text/x-python",
538 "name": "python",
539 "nbconvert_exporter": "python",
540 "pygments_lexer": "ipython3",
541 "version": "3.10.9"
542 }
543 },
544 "nbformat": 4,
545 "nbformat_minor": 2
546}