scraperjavascript10330
VPLink.in URL Resolver & Safelink Scraper
Scraper dan bypasser redirect safelink untuk vplink.in / vplinks.in. Mengekstrak metadata OpenGraph (og:title, og:description, og:image) serta destination URL akhir tanpa harus menunggu timer iklan.
Vamz Spectre24 Okt 2026320 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/vplink-scraper" -o vplink-scraper.js
# 2. Jalankan script
node vplink-scraper.js
vplink-scraper.js(320 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/**
* ========================================================
* Name: VPLink.in URL Resolver & Safelink Scraper
*
* Cara Download:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/vplink-scraper" -o vplink-scraper.js
*
* Cara Eksekusi:
* node vplink-scraper.js "https://vplink.in/GuKTR"
* node vplink-scraper.js "https://vplink.in/7UyP"
*
* Author: Vamz Spectre
* Source: https://vamxapi.my.id
* ========================================================
*/
const DEFAULT_USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
class CookieJar {
constructor() {
this.cookies = new Map();
}
ingest(headers) {
if (!headers) return;
let list = [];
if (typeof headers.getSetCookie === "function") {
list = headers.getSetCookie();
} else if (headers.get && headers.get("set-cookie")) {
list = [headers.get("set-cookie")];
} else if (headers["set-cookie"]) {
list = Array.isArray(headers["set-cookie"]) ? headers["set-cookie"] : [headers["set-cookie"]];
}
for (const item of list) {
if (!item) continue;
const [pair] = item.split(";");
const idx = pair.indexOf("=");
if (idx > 0) {
const k = pair.slice(0, idx).trim();
const v = pair.slice(idx + 1).trim();
if (v && v !== "deleted") {
this.cookies.set(k, v);
} else if (v === "deleted") {
this.cookies.delete(k);
}
}
}
}
get(name) {
return this.cookies.get(name);
}
set(name, value) {
this.cookies.set(name, value);
}
header() {
return [...this.cookies.entries()].map(([k, v]) => `${k}=${v}`).join("; ");
}
}
/**
* Helper fetch with CookieJar and timeout
*/
async function fetchWithJar(targetUrl, opts = {}, jar = null) {
const method = opts.method || "GET";
const headers = {
"User-Agent": DEFAULT_USER_AGENT,
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,application/json,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.9,id;q=0.8",
...(opts.headers || {}),
};
if (jar) {
const c = jar.header();
if (c) headers["Cookie"] = c;
}
const controller = new AbortController();
const timeoutMs = opts.timeout || 15000;
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
try {
const res = await fetch(targetUrl, {
method,
headers,
body: opts.body,
redirect: opts.redirect || "follow",
signal: controller.signal,
});
clearTimeout(timeoutId);
if (jar) jar.ingest(res.headers);
const text = await res.text();
return {
status: res.status,
headers: res.headers,
url: res.url,
text,
};
} catch (err) {
clearTimeout(timeoutId);
throw err;
}
}
/**
* Resolves vplink.in shortened link to destination URL & metadata
* @param {string} shortUrl Target shortened URL e.g. https://vplink.in/GuKTR
* @param {object} options Optional settings { proxy, timeout }
*/
async function scrapeVpLink(shortUrl, options = {}) {
const rawUrl = (shortUrl || "").trim();
if (!rawUrl) throw new Error("Parameter 'url' wajib disertakan.");
const codeMatch = rawUrl.match(/vplink\.(?:in|com)\/([a-zA-Z0-9_-]+)/i);
if (!codeMatch) {
throw new Error(
"URL tidak valid. Format harus berupa link vplink.in (contoh: https://vplink.in/GuKTR)"
);
}
const code = codeMatch[1];
const canonicalUrl = `https://vplink.in/${code}`;
const redirectChain = [canonicalUrl];
const jar = new CookieJar();
let metadata = {
title: null,
description: null,
ogImage: null,
};
// Helper parser for metadata
function extractMetadata(html) {
const titleMatch =
html.match(/<meta[^>]*property=["']og:title["'][^>]*content=["']([^"']+)["']/i) ||
html.match(/<title[^>]*>([^<]+)<\/title>/i);
const descMatch =
html.match(/<meta[^>]*property=["']og:description["'][^>]*content=["']([^"']+)["']/i) ||
html.match(/<meta[^>]*name=["']description["'][^>]*content=["']([^"']+)["']/i);
const imgMatch =
html.match(/<meta[^>]*property=["']og:image["'][^>]*content=["']([^"']+)["']/i);
if (titleMatch && !metadata.title) metadata.title = titleMatch[1].trim();
if (descMatch && !metadata.description) metadata.description = descMatch[1].trim();
if (imgMatch && !metadata.ogImage) metadata.ogImage = imgMatch[1].trim();
}
let finalDestination = null;
let isVpnBlocked = false;
// Step 1: Request inisial ke vplink landing page
const initialRes = await fetchWithJar(canonicalUrl, { timeout: options.timeout }, jar);
const initialHtml = initialRes.text;
extractMetadata(initialHtml);
if (initialHtml.includes("VPN Detected") || initialHtml.includes("isVPNDetected = true")) {
isVpnBlocked = true;
}
// Cari redirect script ke blog partner (pipefitter.in dsb)
let hopMatch =
initialHtml.match(/window\.location\.href\s*=\s*["']([^"']+)["']/i) ||
initialHtml.match(/<a[^>]*href=["']([^"']+)["'][^>]*>click here<\/a>/i);
if (hopMatch) {
let nextUrl = hopMatch[1].replace(/\\\//g, "/");
if (!redirectChain.includes(nextUrl)) redirectChain.push(nextUrl);
let currentReferer = canonicalUrl;
let currentHop = nextUrl;
const maxHops = 10;
for (let i = 0; i < maxHops; i++) {
try {
const hopRes = await fetchWithJar(
currentHop,
{
headers: { Referer: currentReferer },
timeout: options.timeout || 10000,
},
jar
);
currentReferer = currentHop;
extractMetadata(hopRes.text);
// Deteksi direct URL redirect di blog partner
const nextJsRedir =
hopRes.text.match(/window\.location\.href\s*=\s*["']([^"']+)["']/i) ||
hopRes.text.match(/document\.location\.href\s*=\s*['"]([^'"]+)['"]/i);
if (nextJsRedir) {
let resolved = nextJsRedir[1].replace(/\\\//g, "/");
if (resolved.startsWith("/")) {
const origin = new URL(currentHop).origin;
resolved = origin + resolved;
}
if (resolved === currentHop || redirectChain.includes(resolved)) {
// Cek apakah ada script learn_more
if (currentHop.includes("studyinsurances") && !currentHop.includes("learn_more.php")) {
const origin = new URL(currentHop).origin;
resolved = `${origin}/studyinsurances/learn_more.php`;
} else if (currentHop.includes("educatestudy") && !currentHop.includes("learn_more.php")) {
const origin = new URL(currentHop).origin;
resolved = `${origin}/educatestudy/learn_more.php`;
} else {
break;
}
}
redirectChain.push(resolved);
currentHop = resolved;
continue;
}
// Jika tidak ada redirect langsung, cek form submission /links/go atau final button
if (currentHop.includes("vplink.in")) {
// Final landing di vplink
const getLinkMatch = hopRes.text.match(/<a[^>]*id=["']get-link["'][^>]*href=["']([^"']+)["']/i);
if (getLinkMatch && getLinkMatch[1] && !getLinkMatch[1].startsWith("javascript") && getLinkMatch[1] !== "#") {
finalDestination = getLinkMatch[1];
}
// Cek token AroShield
const aroMatch = hopRes.text.match(/token:\s*["']([^"']+)["']/i);
const formTokenMatch = hopRes.text.match(/name=["']_csrfToken["'][^>]*value=["']([^"']+)["']/i);
const adFormDataMatch = hopRes.text.match(/name=["']ad_form_data["'][^>]*value=["']([^"']+)["']/i);
if (formTokenMatch && adFormDataMatch) {
jar.set("csrfToken", formTokenMatch[1]);
jar.set("ab", "2");
const postData = new URLSearchParams({
_method: "POST",
_csrfToken: formTokenMatch[1],
ad_form_data: adFormDataMatch[1],
...(aroMatch ? { arolinks_sec_token: aroMatch[1] } : {}),
});
// Kirim request links/go
const goRes = await fetchWithJar(
"https://vplink.in/links/go",
{
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest",
Referer: currentHop,
},
body: postData.toString(),
timeout: 10000,
},
jar
);
try {
const goJson = JSON.parse(goRes.text);
if (goJson.url && goJson.url !== "#") {
finalDestination = goJson.url;
if (!redirectChain.includes(finalDestination)) redirectChain.push(finalDestination);
}
} catch {}
}
break;
}
break;
} catch {
break;
}
}
}
const isResolved = Boolean(finalDestination && finalDestination !== "#");
return {
status: isResolved || !isVpnBlocked,
shortUrl: canonicalUrl,
code,
destination: finalDestination,
resolved: isResolved,
...(isVpnBlocked && !isResolved
? {
note: "IP Datacenter/VPS terdeteksi oleh vplink edge (VPN Detected). Jalankan melalui koneksi IP residensial/lokal atau proxy.",
}
: {}),
metadata: {
title: metadata.title || null,
description: metadata.description || null,
ogImage: metadata.ogImage || null,
},
redirectChain,
};
}
if (typeof module !== "undefined" && module.exports) {
module.exports = { scrapeVpLink };
}
// CLI Runner
const targetUrl = process.argv[2];
if (targetUrl) {
scrapeVpLink(targetUrl)
.then((res) => {
console.log(JSON.stringify(res, null, 2));
})
.catch((err) => {
console.error(JSON.stringify({ status: false, error: err.message }, null, 2));
process.exit(1);
});
} else if (process.argv[1] && process.argv.length <= 2) {
console.log('Usage: node vplink-scraper.js "https://vplink.in/GuKTR"');
}