Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/social-media/savefrom.js
1126 views
import got from 'got';1import vm from 'vm';2import { ScraperError } from '../utils.js';3export default async function savefrom(url) {4var _a, _b;5let scriptJS = await got('https://worker.sf-tools.com/savefrom.php', {6method: 'POST',7headers: {8'content-type': 'application/x-www-form-urlencoded',9origin: 'https://id.savefrom.net',10referer: 'https://id.savefrom.net/',11'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'12},13form: {14sf_url: encodeURI(url),15sf_submit: '',16new: 2,17lang: 'id',18app: '',19country: 'id',20os: 'Windows',21browser: 'Chrome',22channel: ' main',23'sf-nomad': 124}25}).text();26const executeCode = '[]["filter"]["constructor"](b).call(a);';27if (scriptJS.indexOf(executeCode) === -1)28throw new ScraperError(`Cannot find execute code\n${scriptJS}`);29scriptJS = scriptJS.replace(executeCode, `30try {31i++;32if (i === 2) scriptResult = ${executeCode.split('.call')[0]}.toString();33else (34${executeCode.replace(/;/, '')}35);36} catch {}37`);38const context = {39scriptResult: '',40i: 041};42vm.createContext(context);43new vm.Script(scriptJS).runInContext(context);44const 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]);45return json;46}47//# sourceMappingURL=savefrom.js.map4849