scraperjavascript174
Goal.com Real-Time Live Score & Football Match Scraper
Scraper Node.js real-time untuk mengambil skor langsung (LIVE), jadwal pertandingan, skor akhir, dan rincian kompetisi sepak bola global dari Goal.com Indonesia.
Vamz Spectre3 Okt 2026235 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/goal-livescore-scraper" -o goal-livescore-scraper.js
# 2. Jalankan script
node goal-livescore-scraper.js
Dependencies npm yang Dibutuhkan:
npm install axios, cheerioPanduan Penggunaan:
// Instalasi Dependencies:
npm install axios cheerio
// Jalankan Script:
node goal-livescore-scraper.js
// Contoh integrasi di Bot WhatsApp (Baileys / Telegram):
const { scrapeGoalLivescore } = require(./goal-livescore-scraper);
async function handleLiveScoreCommand(sock, remoteJid) {
const data = await scrapeGoalLivescore({ status: 'live' });
if (data.summary.liveMatches === 0) {
return sock.sendMessage(remoteJid, { text: 'Saat ini belum ada pertandingan sepak bola yang sedang berlangsung (LIVE).' });
}
let text = '⚽ *GOAL.COM LIVE SCORES* ⚽\n\n';
for (const comp of data.competitions) {
text += `🏆 *${comp.competition.name}* (${comp.competition.area})\n`;
for (const m of comp.matches) {
const min = m.period?.display || 'LIVE';
text += `⏱️ [${min}] ${m.teamHome.name} ${m.teamHome.score} - ${m.teamAway.score} ${m.teamAway.name}\n`;
}
text += '\n';
}
await sock.sendMessage(remoteJid, { text: text.trim() });
}goal-livescore-scraper.js(235 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/**
* Goal.com Live Score & Football Match Scraper
* Author: Vamz Spectre (VamxAPI)
* License: MIT
* Dependencies: axios, cheerio
*/
const axios = require("axios");
const cheerio = require("cheerio");
const GOAL_BASE = "https://www.goal.com";
const USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";
/**
* Mengambil live score dan jadwal pertandingan dari Goal.com
* @param {Object} options
* @param {string} [options.status='all'] - 'all', 'live', 'fixture', atau 'result'
* @param {string} [options.search] - Kata kunci pencarian nama tim atau kompetisi
* @param {string} [options.league] - Filter spesifik nama liga / turnamen
* @param {string} [options.group='league'] - 'league' (per turnamen) atau 'flat' (list datar)
*/
async function scrapeGoalLivescore(options = {}) {
const { status = "all", search = "", league = "", group = "league" } = options;
const res = await axios.get(`${GOAL_BASE}/id/livescore`, {
headers: {
"User-Agent": USER_AGENT,
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
},
timeout: 15000,
});
const $ = cheerio.load(res.data);
const nextDataRaw = $("#__NEXT_DATA__").html();
if (!nextDataRaw) {
throw new Error("Gagal mengekstrak data dari Goal.com: __NEXT_DATA__ tidak ditemukan.");
}
const parsed = JSON.parse(nextDataRaw);
const rawLiveScores = parsed.props?.pageProps?.content?.liveScores || [];
const normalizedStatus = status.toUpperCase().trim();
const searchLower = search.toLowerCase().trim();
const leagueLower = league.toLowerCase().trim();
const results = [];
let totalMatchesCount = 0;
let liveMatchesCount = 0;
for (const compGroup of rawLiveScores) {
const competition = {
id: compGroup.competition?.id || "",
name: compGroup.competition?.name || "Unknown Competition",
area: compGroup.competition?.area?.name || "",
logo: compGroup.competition?.image?.url || "",
};
if (leagueLower && !competition.name.toLowerCase().includes(leagueLower)) {
continue;
}
const matches = [];
for (const m of compGroup.matches || []) {
const matchStatus = (m.status || "UNKNOWN").toUpperCase();
if (matchStatus === "LIVE") liveMatchesCount++;
if (normalizedStatus !== "ALL") {
if (normalizedStatus === "LIVE" && matchStatus !== "LIVE") continue;
if (normalizedStatus === "FIXTURE" && matchStatus !== "FIXTURE") continue;
if (normalizedStatus === "RESULT" && matchStatus !== "RESULT") continue;
}
const teamAName = m.teamA?.name || m.teamA?.full || "Team A";
const teamBName = m.teamB?.name || m.teamB?.full || "Team B";
if (searchLower) {
const matchesComp = competition.name.toLowerCase().includes(searchLower);
const matchesTeamA = teamAName.toLowerCase().includes(searchLower);
const matchesTeamB = teamBName.toLowerCase().includes(searchLower);
if (!matchesComp && !matchesTeamA && !matchesTeamB) {
continue;
}
}
const matchUrl =
m.link?.slug && m.id ? `${GOAL_BASE}/id/pertandingan/${m.link.slug}/${m.id}` : null;
const formattedMatch = {
id: m.id,
status: matchStatus,
startDate: m.startDate,
period: m.period
? {
type: m.period.type || null,
minute: typeof m.period.minute === "number" ? m.period.minute : null,
extra: typeof m.period.extra === "number" ? m.period.extra : null,
display: m.period.minute !== undefined ? `${m.period.minute}'` : null,
}
: null,
round: m.round?.name || null,
gameset: m.gameset?.name || null,
venue: m.venue?.name || null,
teamHome: {
id: m.teamA?.id || null,
name: teamAName,
short: m.teamA?.short || null,
code: m.teamA?.code || null,
logo: m.teamA?.image?.url || null,
score: m.score?.teamA !== undefined ? m.score.teamA : null,
redCards: m.redCards?.teamA || 0,
},
teamAway: {
id: m.teamB?.id || null,
name: teamBName,
short: m.teamB?.short || null,
code: m.teamB?.code || null,
logo: m.teamB?.image?.url || null,
score: m.score?.teamB !== undefined ? m.score.teamB : null,
redCards: m.redCards?.teamB || 0,
},
penalty: m.penalty || null,
aggregate: m.agg || null,
matchUrl,
};
matches.push(formattedMatch);
totalMatchesCount++;
}
if (matches.length > 0) {
results.push({
competition,
totalMatches: matches.length,
matches,
});
}
}
const summary = {
totalCompetitions: results.length,
totalMatches: totalMatchesCount,
liveMatches: liveMatchesCount,
filter: { status: normalizedStatus, search: search || null, league: league || null, group },
updatedAt: new Date().toISOString(),
};
if (group === "flat") {
const flatMatches = [];
for (const grp of results) {
for (const m of grp.matches) {
flatMatches.push({ competition: grp.competition, ...m });
}
}
return { summary, matches: flatMatches };
}
return { summary, competitions: results };
}
/**
* Mengambil rincian detail pertandingan (lineup, event gol/kartu, wasit, stats)
*/
async function scrapeGoalMatchDetail(identifier) {
let targetUrl = "";
if (typeof identifier === "string" && identifier.startsWith("http")) {
targetUrl = identifier;
} else if (typeof identifier === "object") {
const { slug, id, url } = identifier;
if (url) targetUrl = url;
else if (slug && id) targetUrl = `${GOAL_BASE}/id/pertandingan/${encodeURIComponent(slug)}/${encodeURIComponent(id)}`;
else if (id) targetUrl = `${GOAL_BASE}/id/pertandingan/_/${encodeURIComponent(id)}`;
}
if (!targetUrl) {
throw new Error("Sertakan { id, slug } atau url pertandingan Goal.com.");
}
const res = await axios.get(targetUrl, {
headers: {
"User-Agent": USER_AGENT,
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
},
timeout: 15000,
});
const $ = cheerio.load(res.data);
const nextDataRaw = $("#__NEXT_DATA__").html();
if (!nextDataRaw) {
throw new Error("Gagal mengekstrak data dari Goal.com: __NEXT_DATA__ tidak ditemukan.");
}
const parsed = JSON.parse(nextDataRaw);
const match = parsed.props?.pageProps?.content?.match;
if (!match) {
throw new Error("Data match tidak ditemukan.");
}
return {
id: match.id,
status: match.status,
startDate: match.startDate,
competition: match.competition,
venue: match.venue,
round: match.round,
referee: match.referee,
teamHome: { ...match.teamA, score: match.score?.teamA ?? null },
teamAway: { ...match.teamB, score: match.score?.teamB ?? null },
period: match.period,
scorers: match.scorers,
events: match.events,
stats: match.stats,
lineups: match.lineups,
};
}
if (typeof module !== "undefined" && module.exports) {
module.exports = {
scrapeGoalLivescore,
scrapeGoalMatchDetail,
};
}
// Contoh eksekusi langsung:
if (require.main === module) {
(async () => {
console.log("=== Goal.com Livescore & Match Scraper ===");
const res = await scrapeGoalLivescore({ status: "all" });
console.log(`Total Kompetisi: ${res.summary.totalCompetitions} | Total Laga: ${res.summary.totalMatches} | Laga LIVE: ${res.summary.liveMatches}`);
})();
}