yuzzoffc / FB DOWNLOADER
Facebook Downloader berbasis node.js/javascript by TT @yuzzoffc
APIJavaScript
5 views
Facebook Downloader berbasis node.js/javascript by TT @yuzzoffc
import axios from "axios";
const INPUT = "https://www.facebook.com/share/v/1CGj5okEfF/";
const API = "https://api.rifkyshre.biz.id";
const ROUTE = "/scrape/facebook";
async function facebook(url = INPUT) {
try {
const res = await axios.post(
`${API}${ROUTE}`,
{ url },
{
timeout: 30000,
validateStatus: () => true,
headers: { "Content-Type": "application/json" },
},
);
const body = res.data;
if (!body?.status) {
return {
Status: false,
Code: body?.code ?? res.status,
Input: url,
Result: null,
Error: body?.error ?? "Unknown error",
};
}
const d = body.data;
return {
Status: true,
Code: body.code,
Input: url,
Result: {
Title: d.title,
Description: d.description,
Thumbnail: d.thumbnail,
HD: d.hd,
SD: d.sd,
},
};
} catch (e) {
return {
Status: false,
Code: e.response?.status ?? 500,
Input: url,
Result: null,
Error: e.message ?? String(e),
};
}
}
console.log(JSON.stringify(await facebook(), null, 2));