Skip to content

Instantly share code, notes, and snippets.

@mtorchiano
Last active March 14, 2016 07:51
Show Gist options
  • Select an option

  • Save mtorchiano/21e94befe002754ef5e5 to your computer and use it in GitHub Desktop.

Select an option

Save mtorchiano/21e94befe002754ef5e5 to your computer and use it in GitHub Desktop.
Classifica Marcatori Serie A
## Python 3 script per scaricare la classifica dei marcatori
##
import urllib.request
from bs4 import BeautifulSoup
print("Downloading page...")
page=urllib.request.urlopen("http://sport.repubblica.it/marcatori/A").read()
print("Parsing and extracting data...")
soup = BeautifulSoup(page,"html.parser")
t = soup.find("table",class_="datatables")
rows = t.find_all("tr")
f= open("Marcatori.csv",'w')
f.write('Giocatore,Squadra,Goal\n')
for m in rows:
els = [e.text.strip() for e in m.find_all("td")]
if len(els)>0:
f.write(", ".join(els)+"\n")
f.close()
print("Done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment