Scraping risultati in diretta

ges

Excel/VBA Expert
Original poster
Amministratore
21 Giugno 2015
30.730
2.820
2.465
Como
2011Mac-365Win
Codice per scaricare tutti i risultati in diretta
Python:
import openpyxl
from bs4 import BeautifulSoup
from datetime import datetime
import requests

wb = openpyxl.Workbook()
sheet = wb.active
url = 'https://www.sportytrader.it/risultati-diretta/'
req = requests.get(url)
soup = BeautifulSoup(req.text, "html.parser")
titles= soup.find_all('a',{'class':'roll-match'})
sheet.cell(row=1,column=1).value = datetime.today().strftime('%Y-%m-%d %H:%M')
i=2
for title in titles:
        i=i+1

        h= title.find('div',{'class':'timer'})
        sheet.cell(row=i,column=1).value = h.text

        teams= title.select('span')
        sheet.cell(row=i,column=2).value =teams[0].text
        sheet.cell(row=i,column=3).value =teams[1].text

        s2= title.find_all('span',{'itemscope':''})[2]
        sheet.cell(row=i,column=4).value =s2.text
        s3= title.find_all('span',{'itemscope':''})[3]
        sheet.cell(row=i,column=5).value =s3.text


wb.save('risultati-diretta.xlsx')

Allego file .exe (il file non si installa, va solo eseguito)
 
Ultima modifica: