wolfyflutter

google search image [21 agustus 2026]

Aug 18th, 2026 (edited)
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.57 KB | Source Code | 0 0
  1. /**
  2.  * google image search 21 agustus 2026
  3.  * skrep mungkin gk akan hidup selamanya
  4.  * karena perlu kuki NID yang valid
  5.  * kalian bisa generate sendiri kalau semisal kukinya dead ya
  6.  * tapi untuk saat ini mungkin masih bisa digunakan, cb aja
  7.  * btw bs aja valuenya detail isi beberapa info kaya w x h, about url, source url dll
  8.  * tapi aku kasih url image aja biar simple haha
  9.  *
  10.  * @param {string} query
  11.  * @returns {string[]} array of string
  12.  * @throws {Error} kalau error :v
  13.  */
  14.  
  15. const googleImageSearch = async (query) => {
  16.   const queryType = typeof query
  17.   if (queryType !== "string" || !query) throw Error(`param query harus string dan gak boleh kosong. ${queryType} diterima`)
  18.  
  19.   const url = new URL("https://www.google.com")
  20.   url.pathname = "/search"
  21.   url.search = new URLSearchParams({
  22.     "as_st": "y",
  23.     "as_q": query,
  24.     "as_epq": "",
  25.     "as_eq": "",
  26.     "as_sitesearch": "",
  27.     "imgar": "",
  28.     "cr": "",
  29.     "as_filetype": "",
  30.     "tbs": "",
  31.     "authuser": "0",
  32.     "udm": "2",
  33.     "safe": "off",   // disable SafeSearch
  34.     "gl": "us",      // serve US results - bypasses region-locked SafeSearch
  35.     "hl": "en"
  36.   })
  37.  
  38.   const r = await fetch(url, {
  39.     "headers": {
  40.       "accept-encoding": "gzip, deflate, br, zstd",
  41.       "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
  42.       "cookie": "NID=534=FRsb06yREkoXVEB8CKNITU5K8HTcx3y741Eg_QDN4MjKxBiuMCD8lcSuZi36lxvEoiUstRhL1COb2LMQZqhfhrHS4OvJIfBK6TZhKzeFNQt6NrgYZDm9LKN0z5fAXb1B02ZMMwImXAHQLO9ogy70znVfQJm6sRtmSFvp20ScBXmUjwx9xE6RX_EdtNBSvB4PGvB-4Tx_eacO31t6eISnAsId8kypbh6oXytpKWK7GBNbdylXU2fSBQTG8xUagI_Q-cwH8Mxt24JPbjiTi1p2FbPXIw",
  43.       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36"
  44.     },
  45.   });
  46.  
  47.   const html = await r.text()
  48.   const match = html.match(/var m=(\{.+?\});var a=m/s)
  49.   if (!match) throw Error(`data block gak ketemu, NID kemungkinan udah mati/diflag (status ${r.status}, page ${html.length} bytes)`)
  50.   const res = eval(`(${match[1]})`)
  51.   const imageUrls = Object.keys(res)
  52.     .map(k => res[k]?.[3]?.[0])
  53.     .filter(url => url?.startsWith('http'))
  54.   return imageUrls
  55. }
  56.  
  57. // cara pakai
  58. try {
  59.   const result = await googleImageSearch("isabelle animal crossing cute fanart") // O.o
  60.   console.log(result)
  61. } catch (e) {
  62.   console.log(`waduh error\n${e.message}`)
  63. }
  64.  
  65. /* result
  66. [
  67.   'https://...60d20d2.png',
  68.   'https://i....d98.jpg',
  69.   'https:...45975952',
  70.   'https://look...',
  71.   ....
  72. }
  73. */
  74.  
Advertisement
Add Comment
Please, Sign In to add comment