-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstagram.js
More file actions
50 lines (48 loc) · 1.54 KB
/
instagram.js
File metadata and controls
50 lines (48 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
let exec = require('child_process').exec
module.exports = (usernameIG) => {
let cmd = 'wget https://instagram.com/'+usernameIG+' -qO -';
let medias = [];
return new Promise((resolve, reject) => {
exec(cmd,function(err,so){
if(err) {
reject(err);
return err;
}
output = so.split('window._sharedData = ')
if(output.length > 1){
let dataScrap = output[1].split(';</script>')
let tojson = JSON.parse(dataScrap[0]);
let userProfile = tojson.entry_data.ProfilePage[0].user
let follower = userProfile.followed_by.count
let following = userProfile.follows.count
let bio = userProfile.biography
let username = userProfile.username
let profilePic = userProfile.profile_pic_url
let fullname = userProfile.full_name
let name = fullname || username
let media = userProfile.media.nodes
if( media.length > 0 ){
for (var i = 0; i < 2; i++) {
if(typeof media[i].thumbnail_src !== 'undefined') {
medias.push(media[i].thumbnail_src);
} else {
medias = ' No Photo Uploaded ';
}
}
} else {
medias = '- User Is Private -';
}
let data = {
userProfile: userProfile.profile_pic_url,
userName: name,
bio : bio,
media: medias,
follow :`Follower: ${follower} <=> Following: ${following}`,
};
resolve(data)
} else {
resolve('not found')
}
})
})
}