Back to Home
Gistify Snippet
Public
NIMFinder — Mahasiswa & NIM Lookup Scraper
Multi-campus Indonesian university student directory scraper supporting ITB, UI, UGM, UNPAD, BINUS, ITS, UNDIP, UNAIR, and more.
#scraper#nim#mahasiswa#indonesia#javascript#tools
0
Rawnimfinder.jsjavascript
117 lines| 1 | /** |
| 2 | * NIMFinder Scraper — Pencarian Nama & NIM Mahasiswa Indonesia |
| 3 | * Base: https://nimfinder.com |
| 4 | * Supported Universities: ITB, UI, UGM, UNPAD, BINUS, UNDIP, ITS, IPB, UNAIR, UNBRAW, dll. |
| 5 | */ |
| 6 | |
| 7 | import fetch from 'node-fetch' |
| 8 | |
| 9 | const BASE_API = 'https://xg1kctvm70.execute-api.ap-southeast-1.amazonaws.com' |
| 10 | const 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' |
| 11 | |
| 12 | export const UNIVERSITIES = { |
| 13 | itb: 'Institut Teknologi Bandung (ITB)', |
| 14 | ui: 'Universitas Indonesia (UI)', |
| 15 | ugm: 'Universitas Gadjah Mada (UGM)', |
| 16 | unpad: 'Universitas Padjadjaran (UNPAD)', |
| 17 | binus: 'Bina Nusantara (BINUS)', |
| 18 | undip: 'Universitas Diponegoro (UNDIP)', |
| 19 | its: 'Institut Teknologi Sepuluh Nopember (ITS)', |
| 20 | ipb: 'IPB University (IPB)', |
| 21 | unair: 'Universitas Airlangga (UNAIR)', |
| 22 | unbraw: 'Universitas Brawijaya (UB/UNBRAW)', |
| 23 | upi: 'Universitas Pendidikan Indonesia (UPI)', |
| 24 | uns: 'Universitas Sebelas Maret (UNS)', |
| 25 | unhas: 'Universitas Hasanuddin (UNHAS)', |
| 26 | unnes: 'Universitas Negeri Semarang (UNNES)', |
| 27 | trisakti: 'Universitas Trisakti (TRISAKTI)' |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Mencari data mahasiswa berdasarkan Nama atau NIM di universitas tertentu |
| 32 | * @param {string} query Nama atau NIM mahasiswa (contoh: "budi", "13520001", "if21") |
| 33 | * @param {string} univ Kode universitas (default: "itb", opsi: "ui", "ugm", "unpad", "binus", "undip", "its", "ipb", "unair", "unbraw") |
| 34 | * @param {number} page Halaman hasil pencarian (default: 0) |
| 35 | */ |
| 36 | export async function searchNim(query, univ = 'itb', page = 0) { |
| 37 | if (!query) throw new Error('Kata kunci pencarian (Nama atau NIM) tidak boleh kosong.') |
| 38 | const targetUniv = univ.toLowerCase().trim() |
| 39 | const validUniv = UNIVERSITIES[targetUniv] ? targetUniv : 'itb' |
| 40 | |
| 41 | try { |
| 42 | const url = `${BASE_API}/mahasiswa_${validUniv}?query=${encodeURIComponent(query)}&page=${page}` |
| 43 | const res = await fetch(url, { |
| 44 | headers: { |
| 45 | 'Origin': 'https://nimfinder.com', |
| 46 | 'Referer': 'https://nimfinder.com/', |
| 47 | 'User-Agent': USER_AGENT, |
| 48 | 'Accept': 'application/json, text/plain, */*' |
| 49 | } |
| 50 | }) |
| 51 | |
| 52 | if (!res.ok) throw new Error(`HTTP Error ${res.status}`) |
| 53 | const json = await res.json() |
| 54 | |
| 55 | if (json.status !== 'OK') { |
| 56 | throw new Error(json.message || 'Gagal mengambil data mahasiswa.') |
| 57 | } |
| 58 | |
| 59 | const list = (json.payload || []).map(item => ({ |
| 60 | name: item.name || item.nama || 'N/A', |
| 61 | nim_tpb: item.nim_tpb || null, |
| 62 | nim_jurusan: item.nim_jur || item.nim || 'N/A', |
| 63 | prodi: item.prodi || item.jurusan || 'N/A', |
| 64 | fakultas: item.fakultas || null, |
| 65 | status: item.status || 'Aktif', |
| 66 | jenis_kelamin: item.jenis_kelamin || null |
| 67 | })) |
| 68 | |
| 69 | return { |
| 70 | university: UNIVERSITIES[validUniv], |
| 71 | university_code: validUniv, |
| 72 | query, |
| 73 | total: json.total || list.length, |
| 74 | page: json.page || page, |
| 75 | results: list |
| 76 | } |
| 77 | } catch (e) { |
| 78 | console.error('[NIMFinder Error]:', e.message) |
| 79 | throw e |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Mencari data mahasiswa di SEMUA universitas besar sekaligus |
| 85 | * @param {string} query Nama atau NIM |
| 86 | */ |
| 87 | export async function searchNimAll(query) { |
| 88 | if (!query) throw new Error('Query tidak boleh kosong.') |
| 89 | const univCodes = Object.keys(UNIVERSITIES) |
| 90 | const promises = univCodes.map(async (code) => { |
| 91 | try { |
| 92 | const data = await searchNim(query, code, 0) |
| 93 | return { |
| 94 | university: UNIVERSITIES[code], |
| 95 | code, |
| 96 | total: data.total, |
| 97 | results: data.results.slice(0, 5) |
| 98 | } |
| 99 | } catch { |
| 100 | return null |
| 101 | } |
| 102 | }) |
| 103 | |
| 104 | const results = (await Promise.all(promises)).filter(r => r && r.results.length > 0) |
| 105 | return { |
| 106 | query, |
| 107 | matched_universities: results.length, |
| 108 | data: results |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | export default { |
| 113 | search: searchNim, |
| 114 | searchAll: searchNimAll, |
| 115 | UNIVERSITIES |
| 116 | } |
| 117 | |
Discussion & Comments0
No comments yet — be the first to leave feedback or start a code discussion.
Sign in with your GitHub account to write comments and join the discussion.