|
|
|
|
@ -3,32 +3,14 @@ const graphql_endpoint = 'https://www.facebook.com/api/graphql/';
|
|
|
|
|
import * as url from 'url'; |
|
|
|
|
import https_proxy_agent from 'https-proxy-agent'; |
|
|
|
|
|
|
|
|
|
const proxies = [ |
|
|
|
|
'176.112.80.253:12323:14ae0dc1e2459:4364101eab', |
|
|
|
|
'176.112.83.69:12323:14ae0dc1e2459:4364101eab', |
|
|
|
|
'176.112.83.203:12323:14ae0dc1e2459:4364101eab', |
|
|
|
|
'176.112.80.150:12323:14ae0dc1e2459:4364101eab', |
|
|
|
|
'176.112.82.121:12323:14ae0dc1e2459:4364101eab' |
|
|
|
|
].map((proxy_str) => { |
|
|
|
|
const [ip, port, user, password] = proxy_str.split(':'); |
|
|
|
|
return { ip, port, user, password }; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const random_int = (max, min) => Math.floor(Math.random() * (max - min) + min); |
|
|
|
|
|
|
|
|
|
export const do_request = async (doc_id, variables, parse = true) => { |
|
|
|
|
const params = new URLSearchParams(); |
|
|
|
|
// const { ip, port, user, password } = proxies[random_int(0, proxies.length)];
|
|
|
|
|
|
|
|
|
|
const ip = '127.0.0.1'; |
|
|
|
|
const port = '24000'; |
|
|
|
|
|
|
|
|
|
let proxyOpts = url.parse(`http://${ip}:${port}`); |
|
|
|
|
// proxyOpts.auth = `${user}:${password}`;
|
|
|
|
|
const agent = new https_proxy_agent(proxyOpts); |
|
|
|
|
params.append('doc_id', doc_id); |
|
|
|
|
params.append('variables', JSON.stringify(variables)); |
|
|
|
|
|
|
|
|
|
const fetch_options = { |
|
|
|
|
headers: { |
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded' |
|
|
|
|
@ -37,7 +19,6 @@ export const do_request = async (doc_id, variables, parse = true) => {
|
|
|
|
|
method: 'POST', |
|
|
|
|
agent |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let res = null; |
|
|
|
|
try { |
|
|
|
|
res = await fetch(graphql_endpoint, fetch_options); |
|
|
|
|
@ -45,14 +26,11 @@ export const do_request = async (doc_id, variables, parse = true) => {
|
|
|
|
|
console.error(e); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const txt = await res.text(); |
|
|
|
|
|
|
|
|
|
if (!res.ok) { |
|
|
|
|
console.error(txt); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (parse) { |
|
|
|
|
try { |
|
|
|
|
res = JSON.parse(txt); |
|
|
|
|
|