wolfyflutter

snapins.ai [instagram] [downloader]

May 20th, 2025 (edited)
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.08 KB | Source Code | 0 0
  1. const snapins = async (urlIgPost) => {
  2.     const headers = {
  3.         "content-type": "application/x-www-form-urlencoded",
  4.     }
  5.  
  6.     const response = await fetch("https://snapins.ai/action.php", {
  7.         headers,
  8.         "body": "url=" + encodeURIComponent(urlIgPost),
  9.         "method": "POST"
  10.     })
  11.  
  12.     if (!response.ok) throw Error (`gagal mendownload informasi. ${response.status} ${response.statusText}`)
  13.    
  14.     const json = await response.json() // kamu bisa console.log json ini langsung dan liat objek nya langsung.
  15.  
  16.     const name = json.data?.[0]?.author?.name || "(no name)"
  17.     const username = json.data?.[0]?.author?.username || "(no username)"
  18.    
  19.     let images = []
  20.     let videos = []
  21.  
  22.     json.data.map(v => {
  23.         if (v.type == "image"){
  24.             images.push(v.imageUrl)
  25.         }else if (v.type == "video"){
  26.             videos.push(v.videoUrl)
  27.         }
  28.     })
  29.  
  30.     return {name, username, images, videos}
  31. }
  32.  
  33. // cara pakek
  34. snapins("https://www.instagram.com/p/C5VRXlaypRw/")
  35. .then(console.log)
  36. .catch(error => console.log(error.message))
Tags: instagram
Add Comment
Please, Sign In to add comment