Spaces:
Paused
Paused
Update lib/instagram.js
Browse files- lib/instagram.js +104 -0
lib/instagram.js
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const { iwaTag, iwa, iwaId, iwaIdUrl } = require('instagram-without-api-node');
|
| 2 |
+
|
| 3 |
+
const _cookie = 'mid=ZPhdOQALAAEgpKJnRtfmsL59XmrP; ig_did=C0FF42A9-CBD9-417C-B895-B5D9960AD3EE; ig_nrcb=1; datr=NF34ZG24OY6-kGRQu_qYqNkQ; csrftoken=gNLpuck17pu7775Fv5uOXCHWoVsWmbKD; ds_user_id=63492274718; sessionid=63492274718%3AbK0cSBlOVegPSh%3A20%3AAYcva8bXz12oNlKL0-X1Hl-M40DG52Aa-465CAF-gg; rur="EAG\05463492274718\0541732761647:01f7b8e316c5fea17dc75001f9183b33c5846c6d5e7c6693e266cba2029dc3196ba67121"' // <!-- required!! please get your cookie from your browser console (6)
|
| 4 |
+
const _userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' // <!-- required!! please get your user-agent from your browser console (7)
|
| 5 |
+
const _xIgAppId = '936619743392459' // <!-- required!! please get your x-ig-app-id from your browser console (8)
|
| 6 |
+
|
| 7 |
+
// get the latest 12 feeds from a tag (example https://instagram.com/explore/tags/love)
|
| 8 |
+
async function insta_iwaTag(tag) {
|
| 9 |
+
const responseIwaTag = await iwaTag({
|
| 10 |
+
|
| 11 |
+
group: 'recent', // <!-- "recent" images or "top" images; "recent" is by default
|
| 12 |
+
base64images: true, // <!-- optional, but without you will be not able to save images.. it increases the size of the json file
|
| 13 |
+
base64imagesCarousel: false, // <!-- optional but not recommended, it increases the size of the json file
|
| 14 |
+
base64videos: false, // <!-- optional but not recommended, it increases the size of the json file
|
| 15 |
+
|
| 16 |
+
headers: {
|
| 17 |
+
'cookie': _cookie,
|
| 18 |
+
'user-agent': _userAgent,
|
| 19 |
+
'x-ig-app-id': _xIgAppId
|
| 20 |
+
},
|
| 21 |
+
|
| 22 |
+
maxImages: 2, // <!-- optional, 12 is the max number
|
| 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 responseIwaTag
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
// get the latest 12 feeds from an account (example https://www.instagram.com/orsifrancesco/)
|
| 35 |
+
async fuintion insta_iwa(username) {
|
| 36 |
+
const responseIwa = await iwa({
|
| 37 |
+
|
| 38 |
+
base64images: true, // <!-- optional, but without you will be not able to save images.. it increases the size of the json file
|
| 39 |
+
base64imagesCarousel: false, // <!-- optional but not recommended, it increases the size of the json file
|
| 40 |
+
base64videos: false, // <!-- optional but not recommended, it increases the size of the json file
|
| 41 |
+
|
| 42 |
+
headers: {
|
| 43 |
+
'cookie': _cookie,
|
| 44 |
+
'user-agent': _userAgent,
|
| 45 |
+
'x-ig-app-id': _xIgAppId
|
| 46 |
+
},
|
| 47 |
+
|
| 48 |
+
maxImages: 2, // <!-- optional, 12 is the max number
|
| 49 |
+
file: "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 functon 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 |
+
return responseIwaId
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
module.exports = { insta_iwaId, insta_iwaIdUrl, insta_iwa, insta_iwaTag }
|