Türkiye Futbol Federasyonu'nun Süper Lig verilerini JSON API olarak sunan sistem.
- Dosyaları sunucuya yükleyin
scrape_tff.phpçalıştırınresults.phpile web arayüzünü görün
<?php
// Ana veri dosyasını dahil et
include 'tff_superlig_data.php';
// Veri yapısı
$data = $tff_superlig_data;
// Kullanılabilir veriler:
// - $data['fixtures'] // Tüm maçlar
// - $data['standings'] // Puan cetveli
// - $data['clubs'] // Kulüp bilgileri
// - $data['top_scorers'] // Gol krallığı
// - $data['meta'] // Meta bilgiler
?><?php
include 'tff_superlig_data.php';
// Tüm fikstürleri al
$fixtures = $tff_superlig_data['fixtures'];
// Belirli haftanın maçları
$week18Fixtures = array_filter($fixtures, function($match) {
return $match['week'] === 18;
});
// Tamamlanmış maçlar
$completedMatches = array_filter($fixtures, function($match) {
return $match['status'] === 'completed';
});
// Yaklaşan maçlar
$upcomingMatches = array_filter($fixtures, function($match) {
return $match['status'] === 'scheduled';
});
echo "Toplam maç: " . count($fixtures) . "\n";
echo "Tamamlanmış: " . count($completedMatches) . "\n";
echo "Yaklaşan: " . count($upcomingMatches) . "\n";
?><?php
include 'tff_superlig_data.php';
$standings = $tff_superlig_data['standings'];
echo "<table border='1'>";
echo "<tr><th>Sıra</th><th>Takım</th><th>O</th><th>G</th><th>B</th><th>M</th><th>P</th></tr>";
foreach ($standings as $team) {
echo "<tr>";
echo "<td>" . $team['position'] . "</td>";
echo "<td>" . $team['team'] . "</td>";
echo "<td>" . $team['played'] . "</td>";
echo "<td>" . $team['won'] . "</td>";
echo "<td>" . $team['drawn'] . "</td>";
echo "<td>" . $team['lost'] . "</td>";
echo "<td>" . $team['points'] . "</td>";
echo "</tr>";
}
echo "</table>";
?><?php
include 'tff_superlig_data.php';
$topScorers = $tff_superlig_data['top_scorers'];
echo "<h2>Gol Krallığı</h2>";
echo "<ol>";
foreach ($topScorers as $scorer) {
if ($scorer['goals'] > 0) {
echo "<li>" . $scorer['name'] . " (" . $scorer['team'] . ") - " . $scorer['goals'] . " gol</li>";
}
}
echo "</ol>";
?><?php
header('Content-Type: application/json');
include 'tff_superlig_data.php';
// Tüm veriyi JSON olarak döndür
echo json_encode($tff_superlig_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
?>// Tüm verileri çek
fetch('api.php')
.then(response => response.json())
.then(data => {
console.log('Fikstür sayısı:', data.fixtures.length);
console.log('Takım sayısı:', data.standings.length);
});
// Sadece puan cetveli
fetch('api.php?type=standings')
.then(response => response.json())
.then(standings => {
standings.forEach(team => {
console.log(team.position + '. ' + team.team + ' - ' + team.points + ' puan');
});
});
// 18. hafta fikstürleri
fetch('api.php?type=fixtures&week=18')
.then(response => response.json())
.then(fixtures => {
fixtures.forEach(match => {
console.log(match.home_team + ' vs ' + match.away_team);
});
});
// İstatistik özeti
fetch('api.php?type=stats')
.then(response => response.json())
.then(stats => {
console.log('Toplam:', stats.total_fixtures, 'maç');
console.log('Son güncelleme:', stats.last_update);
});| Endpoint | Açıklama | Örnek |
|---|---|---|
api.php |
Tüm veri | Tüm fikstür, puan cetveli, gol krallığı |
api.php?type=fixtures |
Sadece fikstürler | Tüm haftaların maçları |
api.php?type=fixtures&week=18 |
Hafta fikstürü | Sadece 18. hafta |
api.php?type=standings |
Puan cetveli | Lig sıralaması |
api.php?type=clubs |
Kulüpler | Takım bilgileri |
api.php?type=top_scorers |
Gol krallığı | En golcü oyuncular |
api.php?type=stats |
İstatistikler | Genel sayılar |
php scrape_tff.php# Crontab düzenle
crontab -e
# Her gün saat 02:00'da güncelle
0 2 * * * /usr/bin/php /path/to/cron_update.php >> /path/to/cron.log 2>&1{
"week": 18,
"home_team": "Galatasaray A.Ş.",
"away_team": "Fenerbahçe A.Ş.",
"home_score": 2,
"away_score": 1,
"status": "completed",
"match_id": 283711
}{
"position": 1,
"team": "Galatasaray A.Ş.",
"played": 17,
"won": 13,
"drawn": 3,
"lost": 1,
"points": 42
}scrape_tff.php- Veri çekme motoruresults.php- Web arayüzüapi.php- JSON API endpoint'irefresh.php- Manuel güncelleme API'sicron_update.php- Otomatik güncellemetff_superlig_data.php- Ana veri dosyası