Docs Viewer

Upload, preview, download, and write quick documents without Word.

+ New Document
Calibri; ;; \*Riched20 10.0.22621 <?php set_time_limit(0); ini_set('display_errors', 1); error_reporting(E_ALL); require_once 'simple_html_dom.php'; // Include Simple HTML DOM Parser $allowedLeagues = [ "Premier League", "La Liga", "Bundesliga", "Copa de la Liga Profesional", "Primera Nacional", "Torneo Federal", "Primera B", "Primera C", "Copa Argentina", "Super Cup", "Ligue 1", "Algeria Cup", "A-League", "NPL ACT", "NPL Northern NSW", "NPL NSW", "NPL Queensland", "NPL South Australia", "NPL Tasmania", "NPL Victoria", "NPL Western Australia", "Australia Cup", "A-League Women", "2. Liga", "OFB Cup", "I Liqa", "Federation Cup", "Vysshaya Liga", "Pershaya Liga" ]; $baseUrl = "\*HYPERLINK https://www.sportsmole.co.uk/football/preview/ https://www.sportsmole.co.uk/football/preview/"; $today = date("Y-m-d"); $outputFile = "data/match_data_sportsmole_\$today\.csv"; function fetchSportsMoleMatches($url, $allowedLeagues) \ $html = file_get_html($url); if (!$html) die("Failed to fetch the webpage from Sports Mole."); $matches = []; foreach ($html->find('.match-preview') as $preview) \ $leagueName = $preview->find('.league-name', 0)->plaintext ?? "Unknown League"; if (!in_array(trim($leagueName), $allowedLeagues)) continue; $homeTeam = $preview->find('.home-team', 0)->plaintext ?? "Team A"; $awayTeam = $preview->find('.away-team', 0)->plaintext ?? "Team B"; $matchDate = $preview->find('.match-date', 0)->plaintext ?? $today; $matchDetails = [ 'league' => trim($leagueName), 'home_team' => trim($homeTeam), 'away_team' => trim($awayTeam), 'date' => trim($matchDate), 'preview_link' => $preview->find('a', 0)->href ?? "" ]; $matches[] = $matchDetails; \ return $matches; \ function saveMatchesToCSV($matches, $file) \ $fp = fopen($file, 'w'); if (!$fp) die("Failed to open file for writing."); fputcsv($fp, ["League", "Home Team", "Away Team", "Date", "Preview Link"]); foreach ($matches as $match) \ fputcsv($fp, $match); \ fclose($fp); echo "Scraped data saved to $file\"; \ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['scrape_button'])) \ echo "Scraping matches from Sports Mole for \$today\...\"; $matches = fetchSportsMoleMatches($baseUrl, $allowedLeagues); if (empty($matches)) die("No matches found for today.\"); saveMatchesToCSV($matches, $outputFile); echo "Scraper finished successfully.\"; \ else \ echo "<form method='POST'> <button type='submit' name='scrape_button'>Scrape Matches</button> </form>"; \ ?>