Last active
March 14, 2016 07:51
-
-
Save mtorchiano/21e94befe002754ef5e5 to your computer and use it in GitHub Desktop.
Classifica Marcatori Serie A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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