Mainly make the python code to make it javascript for nuxt to access.

Python is just used for testing stuff, as it is a fine lang to do so.
This commit is contained in:
yuanhau 2025-05-18 09:28:08 +08:00
parent 81012f5061
commit 5f78e8c58a
9 changed files with 71 additions and 2 deletions

View file

@ -1,3 +1,24 @@
export default defineEventHandler(async (event) => {
return "logging out...";
const loginCookie = getCookie(event, "session");
const lastCheckCookie = getCookie(event, "last_check");
const nowDate = new Date().toLocaleString();
try {
if (loginCookie) {
deleteCookie(event, "session");
setCookie(event, "lastCheckCookie", nowDate, {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
path: "/",
});
return {
success: true,
error: null,
};
}
} catch (e) {
return {
success: false,
error: e.message,
};
}
});

View file

@ -0,0 +1,23 @@
import JSSoup from "jssoup";
async function lineToday(slug: string) {
const url = "https://today.line.me/tw/v2/article/" + slug;
const fetchPageCode = await fetch(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
Accept: "*",
"Accept-Language": "zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"Accept-Encoding": "gzip, deflate, br",
Connection: "keep-alive",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "same-origin",
"Cache-Control": "max-age=0",
},
});
const data = fetchPageCode.text();
const soup = new JSSoup(data);
}
export default lineToday;