downloaderjavascript3110
Getty Images Downloader & Metadata Scraper (Node.js)
Engine scraper media Getty Images resmi tanpa sesi login / API key berbayar. Mengambil judul foto, fotografer (author), deskripsi lengkap, tanggal upload, tag keywords, thumbnail, dan link download media resolusi tinggi.
Vamz Spectre30 Sep 2026166 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/getty-images-downloader" -o getty-images-downloader.js
# 2. Jalankan script
node getty-images-downloader.js
Dependencies npm yang Dibutuhkan:
npm install cheerioPanduan Penggunaan:
// Instalasi Dependencies:
npm install cheerio
// Penggunaan CLI / Terminal:
node getty-images-downloader.js "https://www.gettyimages.com/detail/photo/business-teamwork-concept-royalty-free-image/1365436662"
// Penggunaan di Bot WhatsApp (Baileys) / Express API:
const { scrapeGettyImages } = require(./getty-images-downloader);
const data = await scrapeGettyImages("https://www.gettyimages.com/detail/photo/1365436662");
console.log(data);
/*
Output:
{
status: true,
result: {
id: "1365436662",
title: "Successful Partnership High-Res Stock Photo",
author: "VioletaStoimenova",
description: "Business people shaking hands in the office...",
upload_date: "2021-12-18",
image_url: "https://media.gettyimages.com/id/1365436662/photo/successful-partnership.jpg?s=612x612&w=0&k=20&c=B1xspe9Q5WMsLc7Hc9clR8MWUL4bsK1MfUdDNVNR2Xg=",
thumbnail_url: "https://media.gettyimages.com/id/1365436662/photo/successful-partnership.jpg?s=170x170&k=20&c=r0FWkt_Itn79ZNVZGllGtILNHxyor4jFrd8sqfsdv7g=",
source_url: "https://www.gettyimages.ca/detail/photo/successful-partnership-royalty-free-image/1365436662"
}
}
*/getty-images-downloader.js(166 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
/**
* Getty Images Downloader & Metadata Scraper (Node.js)
*
* Engine scraper media Getty Images resmi tanpa sesi login / cookies berbayar.
* Mengambil judul foto, fotografer (author), deskripsi lengkap, tanggal upload,
* tag keywords, URL thumbnail, dan link download media resolusi tinggi (612x612+).
*
* Base Scraping: https://www.gettyimages.com/
* Platform: VamxAPI (https://vamxapi.my.id)
* Author: Vamz Spectre
*/
const { spawnSync } = require("child_process");
const cheerio = require("cheerio");
/**
* Melacak redirect regional Getty Images ke URL kanonis foto
* @param {string} startUrl - URL awal
* @returns {string} URL kanonis final
*/
function resolveGettyUrl(startUrl) {
let curr = startUrl;
for (let i = 0; i < 5; i++) {
try {
const res = spawnSync("curl", [
"-s", "-I",
"-H", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
curr,
]);
const header = res.stdout ? res.stdout.toString() : "";
const locM = header.match(/location:\s*([^\r\n]+)/i);
if (!locM) break;
const loc = locM[1].trim();
if (loc.startsWith("http")) {
curr = loc;
} else {
const u = new URL(curr);
curr = u.origin + loc;
}
} catch {
break;
}
}
return curr;
}
/**
* Download & ekstrak data foto dari Getty Images
* @param {string} inputUrl - URL foto Getty Images (contoh: https://www.gettyimages.com/detail/photo/...)
* @returns {Promise<Object>} Metadata foto dan direct link download media
*/
async function scrapeGettyImages(inputUrl) {
if (!inputUrl || typeof inputUrl !== "string") {
throw new Error("URL Getty Images wajib disertakan.");
}
let cleanUrl = inputUrl.trim();
// Dukungan input ID foto numerik murni
if (/^\d+$/.test(cleanUrl)) {
cleanUrl = `https://www.gettyimages.com/detail/photo/${cleanUrl}`;
}
if (!cleanUrl.includes("gettyimages")) {
throw new Error("URL yang dimasukkan bukan tautan resmi Getty Images.");
}
const finalUrl = resolveGettyUrl(cleanUrl);
const pageRes = spawnSync("curl", [
"-s",
"-H", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
finalUrl,
], { maxBuffer: 25 * 1024 * 1024 });
const stdout = pageRes.stdout ? pageRes.stdout.toString() : "";
if (!stdout || stdout.length < 500) {
throw new Error("Halaman Getty Images tidak merespon atau konten tidak ditemukan.");
}
const $ = cheerio.load(stdout);
// Ekstraksi Metadata Schema.org & OpenGraph
const title =
$("meta[itemprop=\"name\"]").attr("content") ||
$("div.schema[itemprop=\"image\"] meta[itemprop=\"name\"]").attr("content") ||
$("meta[property=\"og:title\"]").attr("content") ||
$("title").text().replace(/\s*\|.*$/, "").trim();
const description =
$("meta[itemprop=\"description\"]").attr("content") ||
$("div.schema[itemprop=\"image\"] meta[itemprop=\"description\"]").attr("content") ||
$("meta[property=\"og:description\"]").attr("content") ||
"";
const author =
$("div.schema[itemprop=\"author\"] meta[itemprop=\"name\"]").attr("content") ||
$("div.schema[itemprop=\"creator\"] meta[itemprop=\"name\"]").attr("content") ||
$("meta[itemprop=\"author\"]").attr("content") ||
"Getty Images Contributor";
let contentUrl =
$("meta[itemprop=\"contentUrl\"]").attr("content") ||
$("meta[property=\"og:image\"]").attr("content") ||
"";
let thumbUrl = $("meta[itemprop=\"thumbnailUrl\"]").attr("content") || "";
const keywords =
$("div.schema[itemprop=\"image\"] meta[itemprop=\"keywords\"]").attr("content") ||
$("meta[itemprop=\"keywords\"]").attr("content") ||
"";
const uploadDate =
$("div.schema[itemprop=\"image\"] meta[itemprop=\"uploadDate\"]").attr("content") ||
$("meta[itemprop=\"uploadDate\"]").attr("content") ||
"";
// Normalisasi entitas HTML pada URL
contentUrl = contentUrl.replace(/&/g, "&");
thumbUrl = thumbUrl.replace(/&/g, "&");
// Ekstraksi ID foto
const idMatch = finalUrl.match(/\/(\d+)(?:\?|$)/) || finalUrl.match(/id\/(\d+)/);
const id = idMatch ? idMatch[1] : null;
if (!contentUrl && !title) {
throw new Error("Foto Getty Images tidak ditemukan atau halaman tidak dapat diakses.");
}
return {
status: true,
result: {
id,
title,
author,
description,
upload_date: uploadDate,
image_url: contentUrl,
thumbnail_url: thumbUrl,
keywords: keywords
? keywords.split(",").slice(0, 10).map((k) => k.trim())
: [],
source_url: finalUrl,
},
};
}
if (typeof module !== "undefined" && module.exports) {
module.exports = { scrapeGettyImages };
}
// Pengujian Langsung CLI:
if (require.main === module) {
const sampleUrl =
process.argv[2] ||
"https://www.gettyimages.com/detail/photo/business-teamwork-concept-royalty-free-image/1365436662";
console.log(`🔍 Mengunduh metadata & gambar Getty Images dari:\n${sampleUrl}\n`);
scrapeGettyImages(sampleUrl)
.then((res) => console.log(JSON.stringify(res, null, 2)))
.catch((err) => console.error("❌ Gagal:", err.message));
}