mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
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:
parent
81012f5061
commit
5f78e8c58a
5
bun.lock
5
bun.lock
@ -27,6 +27,7 @@
|
||||
"groq-sdk": "^0.21.0",
|
||||
"gsap": "^3.13.0",
|
||||
"html-to-json-parser": "^2.0.1",
|
||||
"jssoup": "^0.0.15",
|
||||
"lucide-vue-next": "^0.508.0",
|
||||
"motion-v": "^1.1.0-alpha.1",
|
||||
"nuxt": "^3.17.2",
|
||||
@ -1370,6 +1371,8 @@
|
||||
|
||||
"html-to-json-parser": ["html-to-json-parser@2.0.1", "", { "dependencies": { "@xmldom/xmldom": "^0.8.10" } }, "sha512-M5m9PnTRbIQCSpj13mecIUThKgWnxDhjEYCjo2PgadXUbYhvJsjY/tyf5AeJDnw0/UPRVAh85VzCxH1bXEX9rw=="],
|
||||
|
||||
"htmlparser": ["htmlparser@1.7.7", "", {}, "sha512-zpK66ifkT0fauyFh2Mulrq4AqGTucxGtOhZ8OjkbSfcCpkqQEI8qRkY0tSQSJNAQ4HUZkgWaU4fK4EH6SVH9PQ=="],
|
||||
|
||||
"http-assert": ["http-assert@1.5.0", "", { "dependencies": { "deep-equal": "~1.0.1", "http-errors": "~1.8.0" } }, "sha512-uPpH7OKX4H25hBmU6G1jWNaqJGpTXxey+YOUizJUAgu0AjLUeC8D73hTrhvDS5D+GJN1DN1+hhc/eF/wpxtp0w=="],
|
||||
|
||||
"http-errors": ["http-errors@2.0.0", "", { "dependencies": { "depd": "2.0.0", "inherits": "2.0.4", "setprototypeof": "1.2.0", "statuses": "2.0.1", "toidentifier": "1.0.1" } }, "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ=="],
|
||||
@ -1496,6 +1499,8 @@
|
||||
|
||||
"jsonfile": ["jsonfile@6.1.0", "", { "dependencies": { "universalify": "^2.0.0" }, "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ=="],
|
||||
|
||||
"jssoup": ["jssoup@0.0.15", "", { "dependencies": { "htmlparser": "^1.7.7" } }, "sha512-9/7qzZQ878Jey0JyNTuy1NYE8Y4G5PbpWQ5hS8vlBD2Ar4MKJNMQ0239yjb+WExRNLiYPSgZSVLyFUwQNWa1ag=="],
|
||||
|
||||
"junk": ["junk@4.0.1", "", {}, "sha512-Qush0uP+G8ZScpGMZvHUiRfI0YBWuB3gVBYlI0v0vvOJt5FLicco+IkP0a50LqTTQhmts/m6tP5SWE+USyIvcQ=="],
|
||||
|
||||
"jwt-decode": ["jwt-decode@4.0.0", "", {}, "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA=="],
|
||||
|
@ -25,6 +25,7 @@ const inputMessage = ref();
|
||||
const messages = ref<chatInterface[]>([]);
|
||||
const messageIndex = ref();
|
||||
const aiGenerating = ref(false);
|
||||
|
||||
// Great, there are now no errors ig
|
||||
const emit = defineEmits(["windowopener", "error", "loadValue"]);
|
||||
const props = defineProps<{
|
||||
|
@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import noImageLogo from "~/public/geterrorassets/noImageLogo.svg";
|
||||
const { t, locale } = useI18n();
|
||||
const eerrrroorr = ref(false);
|
||||
const errorMsg = ref("");
|
||||
|
||||
// Great, there are now no errors ig
|
||||
const emit = defineEmits(["windowopener", "error", "loadValue"]);
|
||||
@ -26,6 +28,10 @@ const {
|
||||
lang: locale,
|
||||
},
|
||||
});
|
||||
if (error) {
|
||||
eerrrroorr.value = true;
|
||||
errorMsg.value = error.value.message;
|
||||
}
|
||||
|
||||
async function getImageSource(image: string) {
|
||||
console.log(image);
|
||||
@ -57,6 +63,14 @@ onMounted(async () => {
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
v-if="eerrrroorr"
|
||||
class="flex flex-col bg-gray-200/50 text-black w-full h-full absolute inset-0 justify-center align-middle text-center z-[20] backdrop-blur-sm"
|
||||
>
|
||||
<div class="m-2">
|
||||
{{ errorMsg }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row flexw-wrap justify-center gap-2">
|
||||
<div
|
||||
class="flex flex-col group bg-gray-900/30 rounded-xl p-3 transition-all duration-500 shadow-lg hover:translate-y-[-2px] ransition-all duration-700"
|
||||
|
@ -13,7 +13,7 @@ try {
|
||||
if (sendError.value) {
|
||||
error.value = true;
|
||||
}
|
||||
if (true) {
|
||||
if (false) {
|
||||
allowed.value = true;
|
||||
} else {
|
||||
allowed.value = false;
|
||||
|
@ -36,6 +36,7 @@
|
||||
"groq-sdk": "^0.21.0",
|
||||
"gsap": "^3.13.0",
|
||||
"html-to-json-parser": "^2.0.1",
|
||||
"jssoup": "^0.0.15",
|
||||
"lucide-vue-next": "^0.508.0",
|
||||
"motion-v": "^1.1.0-alpha.1",
|
||||
"nuxt": "^3.17.2",
|
||||
|
2
public/agents.txt
Normal file
2
public/agents.txt
Normal file
@ -0,0 +1,2 @@
|
||||
# What does this website do?
|
||||
This website mainly do news compare & news analyze stuff.
|
@ -42,9 +42,11 @@ try:
|
||||
req = Request(url, headers=headers)
|
||||
response = urlopen(req)
|
||||
if response.info().get('Content-Encoding') == 'gzip':
|
||||
print("GZIP")
|
||||
gzip_file = gzip.GzipFile(fileobj=io.BytesIO(response.read()))
|
||||
html = gzip_file.read().decode('utf-8')
|
||||
else:
|
||||
print("Not GZIP")
|
||||
html = response.read().decode('utf-8')
|
||||
|
||||
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
23
server/scrape/line_today.ts
Normal file
23
server/scrape/line_today.ts
Normal 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;
|
Loading…
x
Reference in New Issue
Block a user