Is it possible to turn the output of data scraped from this website into a dataframe?

Viewed 18

I've used selenium to scrape a website to get the players statistics from their latest match up.

My code:

from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://www.afl.com.au/matches/3013#player-stats")

main = driver.find_element_by_id("main-content")
print(main.text)

This produces an output similar to this, I am trying to find a way to be able to enter it to a dataframe so that I can export it to a CSV. Alternativetly, is there anyway I can directly export it as a CSV without turning it into a DataFrame?

16
Jake
Aarts
55 1 2 16 10 6 1 3 0 0 179 2 77
12
David
Astbury
38 0 0 12 5 7 3 0 0 0 128 0 94
7
Liam
Baker
81 0 1 20 10 10 8 2 0 0 264 1 77
21
Noah
Balta
40 0 0 11 6 5 3 2 0 0 157 0 85
26
Josh
Battle
84 0 0 19 13 6 8 2 0 1 274 0 81
15
Jack
Billings
57 0 0 14 6 8 5 2 0 0 204 0 78
29
Shai
Bolton
107 1 0 29 15 14 5 3 0 8 431 1 74
35
Nathan
Broad
59 0 0 12 9 3 6 2 0 0 208 0 88
16
Dan
Butler
43 1 0 11 4 7 2 1 0 0 203 0 91
23

This is my first time attempting to scrape data, I've looked into using Pandas however, I am just unsure exactly how to implement that in this situation.

0 Answers
Related