mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
feat: update Google RSS feed handling and improve template rendering
This commit is contained in:
parent
5f897f1bd0
commit
8198010268
@ -11,14 +11,25 @@ try {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
{{ ffeed }}
|
||||
<hr/>
|
||||
<div v-for="item in ffeed">
|
||||
<h2>{{ item.title }}</h2>
|
||||
<span>{{ item.title }}
|
||||
<span v-if="item.title.includes('.cn') || item.title.includes('健康2.0') ||
|
||||
item.title.includes('中天') || item.title.includes('TVBS') ||
|
||||
item.title.includes('香港01')"
|
||||
class="text-red-500 text-sm">
|
||||
- 疑似來自有中資背景公司
|
||||
</span>
|
||||
</span>
|
||||
<h4>{{ item.date }}</h4>
|
||||
類似項目:
|
||||
類似新聞:
|
||||
<div v-for="itit in item.content">
|
||||
{{ itit }}
|
||||
<ul v-for="ititit in itit">
|
||||
<li>
|
||||
- {{ ititit.content?.[0].content[0] }} - {{ ititit.content?.[2].content[0] }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr/>
|
||||
</div>
|
||||
|
@ -8,12 +8,13 @@ export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const feed = await parser.parseURL('https://news.google.com/rss?&hl=zh-TW&gl=TW&ceid=TW:zh-Hant')
|
||||
feed.items.forEach(async (item) => {
|
||||
const relatedNews = JSON.parse(await HTMLToJSON(item.content, true))
|
||||
const rawRelatedNews = await HTMLToJSON(item.content, true)
|
||||
const relatedNews = JSON.parse(rawRelatedNews.replace("ol", ""))
|
||||
array.push({
|
||||
title: item.title,
|
||||
link: item.link,
|
||||
date: item.pubDate,
|
||||
relatedNews: relatedNews
|
||||
content: relatedNews
|
||||
});
|
||||
console.log(item.title);
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user