Kembali ke Beranda
Gistify Snippet
kyiov
Jun 28·1 file(s)
Public

igStalk.js

synced from github gist igStalk.js

#scraper#downloader
igStalk.jsjavascript
106 baris
1import axios from 'axios';
2
3function generateRandomIP() {
4 const ranges = [
5 [1, 1], [2, 2], [5, 5], [23, 23], [27, 27], [31, 31], [36, 36], [37, 37], [39, 39], [42, 42],
6 [46, 46], [49, 49], [50, 50], [60, 60], [114, 114], [117, 117], [118, 118], [119, 119], [120, 120],
7 [121, 121], [122, 122], [123, 123], [124, 124], [125, 125], [126, 126], [180, 180], [182, 182], [183, 183]
8 ];
9 const range = ranges[Math.floor(Math.random() * ranges.length)];
10 const ip = [
11 range[0],
12 Math.floor(Math.random() * 256),
13 Math.floor(Math.random() * 256),
14 Math.floor(Math.random() * 256)
15 ].join('.');
16 return ip;
17}
18
19export const toolDefinition = {
20 name: 'instagram_stalk',
21 description: 'Getting Instagram Profile Information.',
22 inputSchema: {
23 type: 'object',
24 properties: {
25 username: {
26 type: 'string',
27 description: 'Account Usermame',
28 }
29 },
30 required: ['username'],
31 },
32};
33
34class SQIRKInstagramScraper {
35 constructor() {
36 this.baseURL = "https://sqirk.com/sqirk/api.php";
37 this.client = axios.create({
38 headers: {
39 "user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36",
40 "accept": "*/*",
41 "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
42 "referer": "https://sqirk.com/sqirk/"
43 }
44 });
45 }
46
47 async getProfile(username) {
48 try {
49 const spoofedIp = generateRandomIP();
50 const response = await this.client.get(this.baseURL, {
51 params: { username },
52 headers: {
53 'X-Forwarded-For': spoofedIp,
54 'X-Real-IP': spoofedIp,
55 'Client-IP': spoofedIp,
56 'True-Client-IP': spoofedIp,
57 'X-Originating-IP': spoofedIp,
58 'X-Cluster-Client-IP': spoofedIp,
59 'Forwarded': `for=${spoofedIp}`
60 }
61 });
62 return response.data;
63 } catch (error) {
64 if (error.response) {
65 throw new Error(`HTTP Error: ${error.response.status}`);
66 }
67 throw new Error(`Scraping error: ${error.message}`);
68 }
69 }
70}
71
72export async function handler(args) {
73 const username = args.username;
74
75 if (!username) {
76 throw new Error('Username parameter is required');
77 }
78
79 try {
80 const sqirk = new SQIRKInstagramScraper();
81 const result = await sqirk.getProfile(username);
82
83 return {
84 content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
85 };
86 } catch (error) {
87 return {
88 content: [{ type: 'text', text: JSON.stringify({ error: 'Request failed', message: error.message }, null, 2) }],
89 isError: true,
90 };
91 }
92}
93
94
95const targetUsername = "prabowo";
96
97console.log(`Sedang memproses data untuk @${targetUsername}...\n`);
98
99try {
100 const hasil = await handler({ username: targetUsername });
101
102 console.log("=== OUTPUT ===");
103 console.log(hasil.content[0].text);
104} catch (error) {
105 console.error("Gagal eksekusi:", error);
106}
Diskusi & Komentar0

Belum ada komentar — jadilah yang pertama memberikan masukan atau diskusi kode.

Masuk dengan akun GitHub untuk menulis komentar dan berdiskusi.