abot-scraper 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +6 -4
- package/package.json +5 -3
- package/src/index.js +2 -2
- package/src/scraper/downloader.js +63 -76
- package/testing.js +70 -0
package/README.MD
CHANGED
@@ -21,9 +21,10 @@ npm i github:ahlulmukh/abot-scraper
|
|
21
21
|
For Downloader
|
22
22
|
|
23
23
|
```js
|
24
|
-
const {
|
24
|
+
const { downloader } = require("@ahlulmukh/abot-scraper");
|
25
25
|
|
26
|
-
|
26
|
+
downloader
|
27
|
+
.ytMP4("https://youtu.be/j_MlBCb9-m8?si=g6KsGM6cHNotU-rH")
|
27
28
|
.then((result) => {
|
28
29
|
console.log(result); // json;
|
29
30
|
})
|
@@ -35,9 +36,10 @@ Downloader.ytMP4("https://youtu.be/j_MlBCb9-m8?si=g6KsGM6cHNotU-rH")
|
|
35
36
|
For Search
|
36
37
|
|
37
38
|
```js
|
38
|
-
const {
|
39
|
+
const { search } = require("@ahlulmukh/abot-scraper");
|
39
40
|
|
40
|
-
|
41
|
+
search
|
42
|
+
.ytPlay("Lagu Terbaru")
|
41
43
|
.then((result) => {
|
42
44
|
console.log(result); // json;
|
43
45
|
})
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "abot-scraper",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.1",
|
4
4
|
"description": "scraper random for downloader and searching",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"scripts": {
|
@@ -18,6 +18,8 @@
|
|
18
18
|
"license": "ISC",
|
19
19
|
"dependencies": {
|
20
20
|
"axios": "^1.5.1",
|
21
|
-
"
|
21
|
+
"axios-cookiejar-support": "^5.0.5",
|
22
|
+
"cheerio": "^1.0.0-rc.12",
|
23
|
+
"tough-cookie": "^5.1.2"
|
22
24
|
}
|
23
|
-
}
|
25
|
+
}
|
package/src/index.js
CHANGED
@@ -1,55 +1,41 @@
|
|
1
1
|
const { default: axios } = require("axios");
|
2
2
|
const cheerio = require("cheerio");
|
3
|
+
const FormData = require("form-data");
|
3
4
|
global.creator = `@abotscraper – ahmuq`;
|
4
5
|
|
5
6
|
module.exports = class Downloader {
|
6
7
|
facebook = (url) => {
|
7
8
|
return new Promise((resolve, reject) => {
|
8
|
-
let config = {
|
9
|
-
url: url,
|
10
|
-
};
|
11
9
|
let headerss = {
|
12
|
-
"
|
13
|
-
|
14
|
-
"
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
"User-Agent":
|
11
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0",
|
12
|
+
Origin: "https://www.fdown.world",
|
13
|
+
referer: "https://www.fdown.world/",
|
14
|
+
"x-requested-with": "XMLHttpRequest",
|
15
|
+
Cookie: "codehap_domain=www.fdown.world",
|
18
16
|
};
|
19
|
-
|
17
|
+
|
18
|
+
const data = {
|
19
|
+
codehap_link: url,
|
20
|
+
codehap: "true",
|
21
|
+
};
|
22
|
+
|
23
|
+
axios("https://www.fdown.world/result.php", {
|
20
24
|
method: "POST",
|
21
|
-
data: new URLSearchParams(Object.entries(
|
25
|
+
data: new URLSearchParams(Object.entries(data)),
|
22
26
|
headers: headerss,
|
23
27
|
})
|
24
28
|
.then(({ data }) => {
|
25
29
|
const $ = cheerio.load(data);
|
26
|
-
const
|
27
|
-
const
|
28
|
-
hd: "",
|
29
|
-
sd: "",
|
30
|
-
audio: "",
|
31
|
-
};
|
32
|
-
|
33
|
-
$(".btns-download a").each((index, element) => {
|
34
|
-
const link = $(element).attr("href");
|
35
|
-
const text = $(element).text();
|
36
|
-
if (text.includes("HD Quality")) {
|
37
|
-
links.hd = link;
|
38
|
-
} else if (text.includes("Normal Quality")) {
|
39
|
-
links.sd = link;
|
40
|
-
} else if (text.includes("Audio Only")) {
|
41
|
-
links.audio = link;
|
42
|
-
}
|
43
|
-
});
|
30
|
+
const videoUrl = $("video source").attr("src");
|
31
|
+
const imageUrl = $("img").attr("src");
|
44
32
|
|
45
33
|
resolve({
|
46
34
|
creator: global.creator,
|
47
35
|
status: 200,
|
48
36
|
result: {
|
49
|
-
|
50
|
-
|
51
|
-
sd: links.sd,
|
52
|
-
audio: links.audio,
|
37
|
+
thumbnail: imageUrl,
|
38
|
+
videoUrl: videoUrl,
|
53
39
|
},
|
54
40
|
});
|
55
41
|
})
|
@@ -96,41 +82,41 @@ module.exports = class Downloader {
|
|
96
82
|
};
|
97
83
|
|
98
84
|
igstory = (username) => {
|
85
|
+
function encodeParameter(username) {
|
86
|
+
const parameter = `-1::${username}::rJP2tBRKf6ktbRqPUBtRE9klgBWb7d`;
|
87
|
+
let encoded = Buffer.from(parameter).toString("base64");
|
88
|
+
encoded = encoded
|
89
|
+
.replace(/[+]/g, ".")
|
90
|
+
.replace(/[/]/g, "_")
|
91
|
+
.replace(/[=]/g, "-");
|
92
|
+
|
93
|
+
return encoded;
|
94
|
+
}
|
99
95
|
return new Promise(async (resolve) => {
|
96
|
+
const headers = {
|
97
|
+
"User-Agent":
|
98
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/",
|
99
|
+
};
|
100
100
|
try {
|
101
|
-
const
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
const hasil = await axios.get(
|
108
|
-
"https://igs.sf-converter.com/api/stories/" + userId
|
109
|
-
);
|
110
|
-
const result = [];
|
111
|
-
hasil.data.result.forEach((item, index) => {
|
112
|
-
const imageUrl =
|
113
|
-
item.image_versions2 &&
|
114
|
-
item.image_versions2.candidates &&
|
115
|
-
item.image_versions2.candidates.length > 0
|
116
|
-
? item.image_versions2.candidates[0].url
|
117
|
-
: null;
|
118
|
-
const videoUrl =
|
119
|
-
item.video_versions && item.video_versions.length > 0
|
120
|
-
? item.video_versions[0].url
|
121
|
-
: null;
|
122
|
-
result.push(imageUrl);
|
123
|
-
if (videoUrl) {
|
124
|
-
result.push(videoUrl);
|
101
|
+
const encodedParameter = encodeParameter(username);
|
102
|
+
const storyData = await axios(
|
103
|
+
`https://instanavigation.net/api/v1/stories/${encodedParameter}`,
|
104
|
+
{
|
105
|
+
method: "GET",
|
106
|
+
headers: headers,
|
125
107
|
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
108
|
+
);
|
109
|
+
const data = storyData.data;
|
110
|
+
const sources = data.stories.map((story) => story.source);
|
111
|
+
return resolve({
|
112
|
+
creator: global.creator,
|
113
|
+
status: 200,
|
114
|
+
result: {
|
115
|
+
user_info: data.user_info,
|
116
|
+
links: sources,
|
117
|
+
},
|
131
118
|
});
|
132
119
|
} catch (error) {
|
133
|
-
console.log(error);
|
134
120
|
return resolve({
|
135
121
|
creator: global.creator,
|
136
122
|
status: false,
|
@@ -143,29 +129,30 @@ module.exports = class Downloader {
|
|
143
129
|
return new Promise((resolve, reject) => {
|
144
130
|
let config = {
|
145
131
|
url: url,
|
146
|
-
|
147
|
-
|
132
|
+
new: 2,
|
133
|
+
lang: "en",
|
134
|
+
app: "",
|
148
135
|
};
|
149
136
|
let headerss = {
|
150
|
-
"sec-ch-ua":
|
151
|
-
'" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
|
152
137
|
"user-agent":
|
153
138
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
154
|
-
Cookie:
|
155
|
-
'PHPSESSID=6jo2ggb63g5mjvgj45f612ogt7; _ga=GA1.2.405896420.1625200423; _gid=GA1.2.2135261581.1625200423; _PN_SBSCRBR_FALLBACK_DENIED=1625200785624; MarketGidStorage={"0":{},"C702514":{"page":5,"time":1625200846733}}',
|
156
139
|
};
|
157
|
-
axios("https://
|
140
|
+
axios("https://snapinsta.app/get-data.php", {
|
158
141
|
method: "POST",
|
159
142
|
data: new URLSearchParams(Object.entries(config)),
|
160
143
|
headers: headerss,
|
161
144
|
})
|
162
145
|
.then(({ data }) => {
|
163
|
-
const
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
146
|
+
const downloadLinks = data.files
|
147
|
+
.map((file) => {
|
148
|
+
if (file.__type === "GraphVideo") {
|
149
|
+
return file.video_url;
|
150
|
+
} else if (file.__type === "GraphImage") {
|
151
|
+
return file.download_url;
|
152
|
+
}
|
153
|
+
return null;
|
154
|
+
})
|
155
|
+
.filter((link) => link !== null);
|
169
156
|
resolve({
|
170
157
|
creator: global.creator,
|
171
158
|
status: 200,
|
package/testing.js
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
// Import Axios (jika di Node.js)
|
2
|
+
const axios = require("axios"); // Hapus baris ini jika di browser
|
3
|
+
|
4
|
+
// Fungsi untuk meng-encode parameter
|
5
|
+
function encodeParameter(username) {
|
6
|
+
// Format parameter: "-1::username::token"
|
7
|
+
const parameter = `-1::${username}::rJP2tBRKf6ktbRqPUBtRE9klgBWb7d`;
|
8
|
+
|
9
|
+
// Encode ke Base64
|
10
|
+
let encoded = Buffer.from(parameter).toString("base64");
|
11
|
+
|
12
|
+
// Ganti karakter khusus
|
13
|
+
encoded = encoded
|
14
|
+
.replace(/[+]/g, ".")
|
15
|
+
.replace(/[/]/g, "_")
|
16
|
+
.replace(/[=]/g, "-");
|
17
|
+
|
18
|
+
return encoded;
|
19
|
+
}
|
20
|
+
|
21
|
+
// Fungsi untuk mengambil data story dari API menggunakan Axios
|
22
|
+
async function fetchStoryData(username) {
|
23
|
+
const baseUrl = "https://instanavigation.net";
|
24
|
+
const encodedParameter = encodeParameter(username);
|
25
|
+
const apiUrl = `${baseUrl}/api/v1/stories/${encodedParameter}`;
|
26
|
+
|
27
|
+
try {
|
28
|
+
// Lakukan permintaan ke API menggunakan Axios
|
29
|
+
const response = await axios.get(apiUrl);
|
30
|
+
|
31
|
+
// Ambil data dari response
|
32
|
+
const data = response.data;
|
33
|
+
return data;
|
34
|
+
} catch (error) {
|
35
|
+
console.error("Error fetching story data:", error.message);
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
// Contoh penggunaan
|
41
|
+
(async () => {
|
42
|
+
const username = "cristiano"; // Ganti dengan username yang diinginkan
|
43
|
+
const storyData = await fetchStoryData(username);
|
44
|
+
|
45
|
+
if (storyData) {
|
46
|
+
console.log("Data Story:", storyData);
|
47
|
+
|
48
|
+
// Simpan data ke localStorage (jika di browser)
|
49
|
+
if (typeof localStorage !== "undefined" && storyData.user_info) {
|
50
|
+
const userInfo = storyData.user_info;
|
51
|
+
localStorage.setItem(
|
52
|
+
userInfo.username,
|
53
|
+
JSON.stringify([
|
54
|
+
userInfo.id,
|
55
|
+
userInfo.full_name,
|
56
|
+
userInfo.profile_pic_url,
|
57
|
+
userInfo.is_private,
|
58
|
+
userInfo.is_verified,
|
59
|
+
userInfo.posts,
|
60
|
+
userInfo.followers,
|
61
|
+
userInfo.following,
|
62
|
+
Date.now(),
|
63
|
+
])
|
64
|
+
);
|
65
|
+
console.log("Data disimpan di localStorage.");
|
66
|
+
}
|
67
|
+
} else {
|
68
|
+
console.log("Gagal mengambil data story.");
|
69
|
+
}
|
70
|
+
})();
|