I am using Python 3.6 Selenium
with Chrome web driver
Trying to scrape data from nhl stats. I can get the data but I am looking to format it to mirror the website's table in excel. I can scrape the data but only able to get one column of the entire data collected.
Below is my code -
#Load Lib
import csv
from selenium import webdriver
#Browser load and player stats
driver = webdriver.Chrome(executable_path=r"ENTER PATH")
driver.get("http://www.nhl.com/stats/player?aggregate=0&gameType=2&report=skatersummary&pos=S&reportType=season&seasonFrom=20162017&seasonTo=20162017&filter=gamesPlayed,gte,1&sort=points,goals,assists")
PlayerStats = driver.find_elements_by_class_name("rt-tr-group")
for post in PlayerStats:
print(post.text)
driver.close()
output
1
Connor McDavid
2016-17
EDM
C
82
30
70
100
27
26
1.22
3
27
1
2
6
1
251
11.9
21:07
24.37
43.22
Sidney Crosby
2016-17
PIT
C
75
44
45
89
17
24
1.19
14
25
0
0
5
1
255
17.3
19:52
24.69
48.23