ditzzsenpai-api
Version:
Simple NPM api for your app
37 lines (36 loc) • 1.07 kB
JavaScript
const axios = require("axios"),
cheerio = require("cheerio");
module.exports = async function (a) {
try {
let { data: t } = await axios.get("https://litequran.net/" + a);
return (
($ = require("cheerio").load(t)),
(json = []),
$("body > main > article > ol > li").each(function (a, t) {
(latin = $(t).find("span.bacaan").text()),
(arti = $(t).find("span.arti").text()),
(bacaan = $(t).find("span.ayat").text()),
(ayat = parseInt(
$(t)
.find("span.ayat")
.attr("title")
.replace(/[^0-9]/gi, "")
)),
json.push({ bacaan: bacaan, latin: latin, arti: arti, ayat: ayat });
}),
{
status: 200,
surat: $("body > main > article > ol > li:nth-child(1) > span")
.attr("title")
.split(" ")[0],
ayat: json.length,
result: json,
}
);
} catch (a) {
return {
status: 500,
message: "Error, Please Report Bug on : https://clp.pw/NN5q8wP",
};
}
}.bind();