Files
marathon-parser/RunMarathon.ps1
alexei.dolgolyov 245fac3efc Add Marathon Bet live stats VBA scraper
- MarathonStats.bas: VBA module that fetches live sports data from
  marathonbet.by using curl (handles gzip compression), parses HTML
  for team names, scores, odds, and outputs to formatted Excel sheet
- RunMarathon.ps1: PowerShell launcher to automate Excel macro execution
- MarathonStats.xlsm: Pre-built workbook with sample output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 22:09:46 +03:00

48 lines
1.6 KiB
PowerShell

$ErrorActionPreference = "Stop"
$basPath = "c:\Users\Alexei\Documents\VBA\MarathonStats.bas"
$savePath = "c:\Users\Alexei\Documents\VBA\MarathonStats.xlsm"
Write-Host "=== Marathon Stats Launcher ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "[1/5] Starting Excel..." -ForegroundColor Yellow
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$excel.DisplayAlerts = $false
Write-Host "[2/5] Creating workbook..." -ForegroundColor Yellow
$workbook = $excel.Workbooks.Add()
Write-Host "[3/5] Importing VBA module..." -ForegroundColor Yellow
try {
$null = $workbook.VBProject.VBComponents.Import($basPath)
Write-Host " Module imported OK" -ForegroundColor Green
} catch {
Write-Host "ERROR: Cannot access VBA project - $_" -ForegroundColor Red
$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null
exit 1
}
Write-Host "[4/5] Running FetchMarathonStats..." -ForegroundColor Yellow
Write-Host " (curl will fetch page, then parse and format)" -ForegroundColor Gray
try {
$excel.Run("FetchMarathonStats")
Write-Host " Macro completed" -ForegroundColor Green
} catch {
Write-Host " Macro error: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "[5/5] Saving workbook..." -ForegroundColor Yellow
try {
if (Test-Path $savePath) { Remove-Item $savePath -Force }
$workbook.SaveAs($savePath, 52)
Write-Host " Saved to: $savePath" -ForegroundColor Green
} catch {
Write-Host " Save error: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host ""
Write-Host "=== Done! ===" -ForegroundColor Cyan