-
Notifications
You must be signed in to change notification settings - Fork 4
/
simple-instagram-scraper.js
41 lines (31 loc) · 1.02 KB
/
simple-instagram-scraper.js
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
const cheerio = require('cheerio');
const request = require('request');
const BASE_URL = 'https://www.instagram.com/';
const getReport = (username) => {
let url = BASE_URL+username;
return new Promise(function(resolve, reject) {
request(url, function(err,resp, body){
if(err)
throw err;
$ = cheerio.load(body);
let content = $('meta').eq('16').attr('content');
content = content.replace(/,/g , '');
let followers = content.substring(0,content.indexOf("Followers")).trim();
let following = content.substring(content.indexOf("Followers")+9,content.indexOf("Following")).trim();
let posts = content.substring(content.indexOf("Following")+9,content.indexOf("Posts")).trim();
let userInfo = {
username: username,
followers: followers,
following: following,
posts: posts,
dateRequested: Date.now() //Unix time
};
resolve(userInfo);
});
});
}
const getPerson = async() => {
let report = await getReport("logic");
console.log(report)
}
module.exports = {getReport};