Update lib/instagram.js
Browse files- lib/instagram.js +58 -96
lib/instagram.js
CHANGED
|
@@ -1,104 +1,66 @@
|
|
| 1 |
-
const
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
headers: {
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
file: "instagram-cache-bytag.json", // <!-- optional, instagram-cache.json is by default
|
| 24 |
-
pretty: true, // <!-- optional, prettyfy json true/false
|
| 25 |
-
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
|
| 26 |
-
|
| 27 |
-
id: tag // <!-- id is required
|
| 28 |
-
|
| 29 |
})
|
| 30 |
-
return
|
| 31 |
}
|
| 32 |
|
| 33 |
-
|
| 34 |
-
//
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
headers: {
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
'x-ig-app-id': _xIgAppId
|
| 46 |
-
},
|
| 47 |
-
|
| 48 |
-
maxImages: 2, // <!-- optional, 12 is the max number
|
| 49 |
-
file: "../tmp/instagram-cache.json", // <!-- optional, instagram-cache.json is by default
|
| 50 |
-
pretty: true, // <!-- optional, prettyfy json true/false
|
| 51 |
-
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
|
| 52 |
-
|
| 53 |
-
id: username // <!-- id is required
|
| 54 |
-
|
| 55 |
-
})
|
| 56 |
-
return responseIwa
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
// get picture and info from instagram id url (example https://www.instagram.com/p/Cgczi6qMuh1/)
|
| 60 |
-
async function insta_iwaIdUrl(id) {
|
| 61 |
-
const responseIwaIdUrl = await iwaIdUrl({
|
| 62 |
-
|
| 63 |
-
headers: {
|
| 64 |
-
'cookie': _cookie,
|
| 65 |
-
'user-agent': _userAgent,
|
| 66 |
-
'x-ig-app-id': _xIgAppId
|
| 67 |
-
},
|
| 68 |
-
|
| 69 |
-
base64images: false, // <!-- optional, but without it, you will be not able to store/show images
|
| 70 |
-
file: "instagram-cache-byidurl.json", // <!-- optional, instagram-cache.json is by default
|
| 71 |
-
pretty: true, // <!-- optional, prettyfy json true/false
|
| 72 |
-
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
|
| 73 |
-
|
| 74 |
-
id: id // <!-- id is required
|
| 75 |
-
|
| 76 |
-
})
|
| 77 |
-
return responseIwaIdUrl
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
// get picture and info from instagram id (2890411760684296309 is the id of https://www.instagram.com/p/Cgczi6qMuh1/)
|
| 82 |
-
async function insta_iwaId(id) {
|
| 83 |
-
const responseIwaId = await iwaId({
|
| 84 |
-
|
| 85 |
-
base64images: true, // <!-- optional, but without you will be not able to save images.. it increases the size of the json file
|
| 86 |
-
base64videos: false, // <!-- optional but not recommended, it increases the size of the json file
|
| 87 |
-
|
| 88 |
-
headers: {
|
| 89 |
-
'cookie': _cookie,
|
| 90 |
-
'user-agent': _userAgent,
|
| 91 |
-
'x-ig-app-id': _xIgAppId
|
| 92 |
-
},
|
| 93 |
-
|
| 94 |
-
file: "instagram-cache-byid.json", // <!-- optional, instagram-cache.json is by default
|
| 95 |
-
pretty: true, // <!-- optional, prettyfy json true/false
|
| 96 |
-
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
|
| 97 |
-
|
| 98 |
-
id: id // <!-- id is required
|
| 99 |
-
|
| 100 |
})
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
-
module.exports = {
|
|
|
|
| 1 |
+
const axios = require("axios")
|
| 2 |
+
const cheerio = require("cheerio")
|
| 3 |
+
|
| 4 |
+
async function sss_instagram(urls) {
|
| 5 |
+
let BASE_URL = "https://sssinstagram.com/pt"
|
| 6 |
+
let cookie = (await axios.get(BASE_URL)).headers["set-cookie"]
|
| 7 |
+
let data_cookie = {
|
| 8 |
+
cookie: cookie[0] + "; " + cookie[1] + "; " + cookie[2],
|
| 9 |
+
token: cookie[1].split(";")[0].replace("XSRF-TOKEN=", "").replace("%3D", "")
|
| 10 |
+
}
|
| 11 |
+
let res = await axios.request({
|
| 12 |
+
method: "POST",
|
| 13 |
+
url: BASE_URL + "/r",
|
| 14 |
+
data: { link: urls, token: ""},
|
|
|
|
| 15 |
headers: {
|
| 16 |
+
"Cookie": data_cookie.cookie,
|
| 17 |
+
"Origin": "https://sssinstagram.com",
|
| 18 |
+
"Referer": "https://sssinstagram.com",
|
| 19 |
+
"X-Requested-With": "XMLHttpRequest",
|
| 20 |
+
"X-Xsrf-Token": data_cookie.token
|
| 21 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
})
|
| 23 |
+
return res.data
|
| 24 |
}
|
| 25 |
|
| 26 |
+
async function gramvio(username) {
|
| 27 |
+
//url
|
| 28 |
+
let BASE_URL = "https://gramvio.com/insta-stalker/"
|
| 29 |
+
// mendatapkan cookie
|
| 30 |
+
let cookie = (await require("axios").get(BASE_URL)).headers["set-cookie"]
|
| 31 |
+
// mendapatkan token
|
| 32 |
+
let response = await axios.request({
|
| 33 |
+
method: "GET",
|
| 34 |
+
url: BASE_URL,
|
| 35 |
headers: {
|
| 36 |
+
"Cookie": cookie[0] + "; " + cookie[1]
|
| 37 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
})
|
| 39 |
+
let $ = cheerio.load(response.data)
|
| 40 |
+
let token = $("meta[name='csrf-token']").attr("content")
|
| 41 |
+
// memasukan data
|
| 42 |
+
const get_response = async(data, id) => {
|
| 43 |
+
formData.append(data, id)
|
| 44 |
+
formData.append("variable", "getprofile")
|
| 45 |
+
|
| 46 |
+
// memasukan data ke server
|
| 47 |
+
let res = await axios.request({
|
| 48 |
+
method: "POST",
|
| 49 |
+
url: BASE_URL,
|
| 50 |
+
data: formData,
|
| 51 |
+
headers: {
|
| 52 |
+
"Cookie": cookie[0] + "; " + cookie[1],
|
| 53 |
+
"Referer": BASE_URL,
|
| 54 |
+
"Origin": BASE_URL,
|
| 55 |
+
"X-CSRF-Token": token,
|
| 56 |
+
"X-Requested-With": "XMLHttpRequest"
|
| 57 |
+
}
|
| 58 |
+
})
|
| 59 |
+
return res.data
|
| 60 |
+
}
|
| 61 |
+
let res_profile = await get_response("username", username)
|
| 62 |
+
let res_post = await get_response("id", res_profile.getprofile.id)
|
| 63 |
+
return res_profile + res_post
|
| 64 |
}
|
| 65 |
|
| 66 |
+
module.exports = { sss_instagram, gramvio}
|