Initial Commit
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
/node_modules
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const cheerio = require("cheerio");
|
||||||
|
const request = require("request");
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
const baseUrl = "https://boxnovel.com/";
|
||||||
|
|
||||||
|
router.get("/latest", (req, res) => {
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
request(baseUrl, (err, response, body) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
$(".page-item-detail").each(function (result) {
|
||||||
|
let novelName = null;
|
||||||
|
|
||||||
|
novelName = $(this).find("h5 > a").text();
|
||||||
|
novelCover = $(this).find("img").attr("src");
|
||||||
|
novelUrl = $(this)
|
||||||
|
.find("h5 > a")
|
||||||
|
.attr("href")
|
||||||
|
.replace(baseUrl + "novel/", "");
|
||||||
|
novel = {
|
||||||
|
novelName: novelName,
|
||||||
|
novelCover: novelCover,
|
||||||
|
novelUrl: novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
Generated
+1769
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "lnreader-backend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Backend for LNReader",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "nodemon server"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"cheerio": "^1.0.0-rc.5",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"request": "^2.88.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^2.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
const express = require("express");
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
express.json({
|
||||||
|
extended: false,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
app.get("/", (req, res) =>
|
||||||
|
res.json({
|
||||||
|
Author: "Rajarshee Chatterjee",
|
||||||
|
Version: "1.0.0",
|
||||||
|
Github: "https://github.com/rajarsheechatterjee/LNReader-backend",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
app.use("/api/", require("./api/latest"));
|
||||||
|
|
||||||
|
const PORT = process.env.PORT || 5000;
|
||||||
|
|
||||||
|
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
|
||||||
Reference in New Issue
Block a user