Skip to content

Commit

Permalink
lastest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosizilio committed Oct 9, 2019
1 parent 401acd9 commit 10c0d06
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
22 changes: 13 additions & 9 deletions insta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fetch = require('node-fetch');
let SocksProxyAgent = require('socks-proxy-agent');
let HttpsProxyAgent = require('https-proxy-agent');
let md5 = require('md5');
let _ = require('lodash');

Expand All @@ -20,28 +21,30 @@ var insta = new function () {
defaultPageSize: 50
}

this.instance = function ({socksUrl}) {
if(socksUrl){
this.agent = new SocksProxyAgent(socksUrl);
this.instance = function (params={}) {

if(params.socksProxyUrl){
this.agent = new SocksProxyAgent(params.socksProxyUrl);
} else if(params.httpsProxyUrl) {
this.agent = new HttpsProxyAgent(params.httpsProxyUrl);
}
return this;
}

this.makeRequest = function ({ queryHash, queryVariables }) {
// console.log(`${this.graphqlURL}?query_hash=${queryHash}&variables=${JSON.stringify(queryVariables)}`);
console.log(`${this.graphqlURL}?query_hash=${queryHash}&variables=${JSON.stringify(queryVariables)}`);

// return fetch("https://ipinfo.io/ip", {
// agent: new SocksProxyAgent('socks://127.0.0.1:9050')
// agent: this.agent
// }).then(res => res.text())
// .then(body => console.log(body));

return fetch(`${this.graphqlURL}?query_hash=${queryHash}&variables=${JSON.stringify(queryVariables)}`,
{
method: 'get',
headers: {
'Content-Type': 'application/json',
'user-agent': "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36",
'Content-Type': 'text/plain'
'Content-Type': 'text/plain',
},
agent: this.agent
})
Expand Down Expand Up @@ -127,20 +130,21 @@ var insta = new function () {

this.getUser = function ({ identifier }) {
let searchUrl = this.searchUserUrl.replace("${username}", identifier);
// console.log(`${searchUrl}`);
console.log(`${searchUrl}`);

return fetch(`${searchUrl}`,
{
method: 'get',
headers: {
'Content-Type': 'application/json',
'user-agent': "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36",
'Content-Type': 'text/plain'
},
agent: this.agent
})
.then(res => res.json())
.then(res => {
console.log(res);

return res.graphql.user;
})
}
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"https-proxy-agent": "^2.2.2",
"lodash": "^4.17.11",
"md5": "^2.2.1",
"node-fetch": "^2.6.0",
Expand Down
26 changes: 14 additions & 12 deletions sample.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
let insta = new require("./insta").instance({ socksUrl: 'socks://127.0.0.1:9050' });
// let insta = new require("./insta").instance({ httpsProxyUrl: 'http://185.61.92.207:34364' });
let insta = new require("./insta").instance();


insta.getUsername({identifier: "26669533"})
.then(data => {
console.log(data); //Threat the data
insta.getUser({identifier: data})
.then(data => {
console.log(data); //Threat the data
})
})
// insta.getUsername({identifier: "26669533"})
// .then(data => {
// console.log(data); //Threat the data
// })

// insta.getUserFollowers({identifier: "26669533", limit: 10})
// insta.getUser({identifier: 'neymarjr'})
// .then(data => {
// console.log(data); //Threat the data
// })

// insta.getUserPosts({identifier: "26669533", limit: 10})
// insta.getUserFollowers({identifier: "26669533", limit: 10})
// .then(data => {
// console.log(data); //Threat the data
// })

// insta.getPostDetails({identifier: "SQotORh6Gz"})
// insta.getUserPosts({identifier: "26669533", limit: 10})
// .then(data => {
// console.log(data); //Threat the data
// })

insta.getPostDetails({identifier: "B2gxtu-o3Oc"})
.then(data => {
console.log(data); //Threat the data
})

// insta.getPostLikes({identifier: "SQotORh6Gz", limit: 80})
// .then(data => {
// console.log(data); //Threat the data
Expand Down

0 comments on commit 10c0d06

Please sign in to comment.