Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/social-media/savefrom.js
1126 views
1
import got from 'got';
2
import vm from 'vm';
3
import { ScraperError } from '../utils.js';
4
export default async function savefrom(url) {
5
var _a, _b;
6
let scriptJS = await got('https://worker.sf-tools.com/savefrom.php', {
7
method: 'POST',
8
headers: {
9
'content-type': 'application/x-www-form-urlencoded',
10
origin: 'https://id.savefrom.net',
11
referer: 'https://id.savefrom.net/',
12
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36'
13
},
14
form: {
15
sf_url: encodeURI(url),
16
sf_submit: '',
17
new: 2,
18
lang: 'id',
19
app: '',
20
country: 'id',
21
os: 'Windows',
22
browser: 'Chrome',
23
channel: ' main',
24
'sf-nomad': 1
25
}
26
}).text();
27
const executeCode = '[]["filter"]["constructor"](b).call(a);';
28
if (scriptJS.indexOf(executeCode) === -1)
29
throw new ScraperError(`Cannot find execute code\n${scriptJS}`);
30
scriptJS = scriptJS.replace(executeCode, `
31
try {
32
i++;
33
if (i === 2) scriptResult = ${executeCode.split('.call')[0]}.toString();
34
else (
35
${executeCode.replace(/;/, '')}
36
);
37
} catch {}
38
`);
39
const context = {
40
scriptResult: '',
41
i: 0
42
};
43
vm.createContext(context);
44
new vm.Script(scriptJS).runInContext(context);
45
const json = JSON.parse((_b = (_a = context.scriptResult.split('window.parent.sf.videoResult.show(')) === null || _a === void 0 ? void 0 : _a[1].split(');')) === null || _b === void 0 ? void 0 : _b[0]);
46
return json;
47
}
48
//# sourceMappingURL=savefrom.js.map
49