CAF1837
Registered User
Just scrape the HTML, not much you can do
Thanks. The game-by-game stats are only available on the actual gamesheets (as far as I know) which are pdf files. Anyways, I'll find a way. Thanks again!
Just scrape the HTML, not much you can do
Sad to say, but this code dosen't work for me There is a hint:This is the raw data for their NHL GameCenter Website/App services, there is no documentation (unless you worked on the infrastructure) but if you don't understand what a certain attribute means, feel free to ask; shouldn't take too long for me to analyze.
Remember that the URL you linked above is in JSONP and thus needs the "loadScoreboard(***DATA***)" to be removed in order to parse it as JSON.
You use PHP, so here is how you convert the JSONP to JSON:
PHP:$dayscores = "http://live.nhle.com/GameData/GCScoreboard/" . $gamedate . ".jsonp"; $rawscores = file_get_contents($dayscores); // Convert JSONP to JSON $rawscores = preg_replace('/.+?(**.+}).+/','$1',$rawscores); $rawscores = json_decode($rawscores, true);
$rawscores = preg_replace("/.+?(**.+}).+/","$1",$rawscores);
I'm looking to put selected players only current seasonal stats into a table. How do i do this the most easiest?
Thanks!
Can you explain "selected players only current seasonal stats" ?
I guess you could pick out their player id's from the table and store them in an array, and then when you search through your database to pull up the stats (Or if you just want to pull it directly from the JSON tables), you could only select ones that match an id in the array.Okey, i want a scoring race that updates automatically with only select players, for example:
1. Alexander Ovechkin
2. Brent Burns
3. Taylor Chorney
Needs only to be updated when loading the page, not like Java or whatever withour reloading. Thanks for tips!
from bs4 import BeautifulSoup
import urllib2
url = "http://www.nhl.com/ice/standings.htm?type=lea#&navid=nav-stn-league"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page, "html.parser")
rows = soup.find("table", width=660).find("tbody").find_all("tr")
for row in rows:
cells = row.find_all("td")
for i in range(0, 17):
print cells[i].get_text()
1
*p - NY Rangers
M
82
53
22
7
113
49
252
192
+60
25-11-5
28-11-2
4-5
7-3-0
Won 1
2
*y - Montréal
A
82
50
22
10
110
43
221
189
+32
26-9-6
24-13-4
7-5
5-2-3
Won 3
3
*z - Anaheim
P
82
51
24
7
109
43
236
226
+10
26-12-3
25-12-4
8-5
6-4-0
Won 1
4
*y - St. Louis
C
82
51
24
7
109
42
248
201
+47
27-12-2
24-12-5
9-4
6-3-1
Won 2
5
*x - Tampa Bay
A
82
50
24
8
108
47
262
211
+51
32-8-1
18-16-7
3-5
6-3-1
Won 3
6
*x - Nashville
C
82
47
25
10
104
41
232
208
+24
28-9-4
19-16-6
6-6
4-4-2
Lost 3
7
*x - Chicago
C
82
48
28
6
102
39
229
189
+40
24-12-5
24-16-1
9-3
4-6-0
Lost 4
8
*x - Vancouver
P
82
48
29
5
101
42
242
222
+20
24-15-2
24-14-3
6-2
6-3-1
Won 3
9
*x - Washington
M
82
45
26
11
101
40
242
203
+39
23-13-5
22-13-6
5-4
6-3-1
Lost 1
10
*x - NY Islanders
M
82
47
28
7
101
40
252
230
+22
25-14-2
22-14-5
7-6
4-3-3
OT 1
11
*x - Minnesota
C
82
46
28
8
100
42
231
201
+30
22-13-6
24-15-2
4-3
6-3-1
Lost 1
12
*x - Detroit
A
82
43
25
14
100
39
235
221
+14
22-10-9
21-15-5
4-10
4-4-2
Won 1
13
*x - Ottawa
A
82
43
26
13
99
37
238
215
+23
23-13-5
20-13-8
6-7
6-2-2
Won 3
14
*x - Winnipeg
C
82
43
26
13
99
36
230
210
+20
23-13-5
20-13-8
7-6
6-3-1
Won 1
15
*x - Pittsburgh
M
82
43
27
12
98
39
221
210
+11
23-14-4
20-13-8
4-6
3-5-2
Won 1
16
*x - Calgary
P
82
45
30
7
97
41
241
216
+25
23-13-5
22-17-2
4-3
6-3-1
Lost 1
17
*Boston
A
82
41
27
14
96
37
213
211
+2
24-10-7
17-17-7
4-10
5-3-2
OT 1
18
*Los Angeles
P
82
40
27
15
95
38
220
205
+15
25-9-7
15-18-8
2-8
5-4-1
Won 1
19
*Dallas
C
82
41
31
10
92
37
261
260
+1
17-16-8
24-15-2
4-3
7-3-0
Won 4
20
*Florida
A
82
38
29
15
91
30
206
223
-17
21-13-7
17-16-8
8-10
5-4-1
Won 2
21
*Colorado
C
82
39
31
12
90
29
219
227
-8
23-15-3
16-16-9
10-4
6-4-0
Won 3
22
*San Jose
P
82
40
33
9
89
36
228
232
-4
19-17-5
21-16-4
4-6
5-4-1
Lost 1
23
*Columbus
M
82
42
35
5
89
33
236
250
-14
19-20-2
23-15-3
9-2
9-0-1
Won 3
24
*Philadelphia
M
82
33
31
18
84
30
215
234
-19
23-11-7
10-20-11
3-11
4-3-3
Lost 2
25
*New Jersey
M
82
32
36
14
78
27
181
216
-35
19-14-8
13-22-6
5-7
1-6-3
Lost 1
26
*Carolina
M
82
30
41
11
71
25
188
226
-38
18-16-7
12-25-4
5-7
4-5-1
Lost 1
27
*Toronto
A
82
30
44
8
68
25
211
262
-51
22-17-2
8-27-6
5-5
3-5-2
OT 1
28
*Edmonton
P
82
24
44
14
62
19
198
283
-85
15-23-3
9-21-11
5-7
4-5-1
OT 1
29
*Arizona
P
82
24
50
8
56
19
170
272
-102
11-25-5
13-25-3
5-5
3-7-0
Lost 3
30
*Buffalo
A
82
23
51
8
54
15
161
274
-113
14-22-5
9-29-3
8-5
3-6-1
Lost 2
<?php
$jsonFile = file_get_contents("http://live.nhle.com/GameData/GCScoreboard/2015-11-04.jsonp");
$jsonArray = explode("(", $jsonFile);
$jsonFile = $jsonArray[1];
$jsonArray = explode(")", $jsonFile);
$jsonFile = $jsonArray[0];
?>
<script type="text/javascript">
var scoreBoard = JSON.parse('<?php echo $jsonFile; ?>');
for (key in scoreBoard.games) {
for (property in scoreBoard.games[key]) {
document.write(property + ": "+ scoreBoard.games[key][property] + "<br>");
}
document.write("<hr>");
}
</script>
for (key in scoreBoard.games) {
document.write(scoreBoard.games[key]["atcommon"] + " " + scoreBoard.games[key]["ats"] + "<br>");
document.write(scoreBoard.games[key]["htcommon"] + " " + scoreBoard.games[key]["hts"] + "<br>");
document.write(scoreBoard.games[key]["bs"] + "<hr>");
}
This is a fantastic thread, and I've been able to make tremendous progress in an app I'm creating because of this. Thank you all for your efforts.
I do have a few questions/requests...
- is there a URL that contains any or all of the following (I would be expecting these IDs to be a numeric value, but wouldn't be surprised if they were text):
TeamId
DivisionID
ConferenceId
- Is there a URL that contains the full season schedule? In my mind, I see it something like:
GameID...GameDate...ATID...HTIDwhere ATID is the away team ID and HTID is the home team ID
I can't find any JSON files for one, but you could create a program to scrape NHL.com and create your own JSON file for the app to call.
Thank you for the effort. I've got Admin tool portion of my app gathering the game day JSON for each day, and loading it into the DB already, but I guess I'm just looking for an easy/lazy way out of doing the kind of initial setup I need
Does anyone have experience with MLBAM-created websites? MLBAM bought all the NHL digital rights in the summer and they are launching a brand new NHL.com website during the All-Star break and then rolling out new club websites and mobile apps in the off-season. This has the very real and serious potential to break any apps that use the links provided in this thread.
http://www.sportsnet.ca/hockey/nhl/a-closer-look-at-nhls-partnership-with-mlbam/
Where could I find/scrape TOI stats? I mean total Time On Ice, not avg toi/game
http://www.nhl.com/stats/rest/indiv...cayenneExp=seasonId=20152016 and gameTypeId=2
Time is given in seconds.