2024-10-09 03:23:19 +08:00
|
|
|
import * as cheerio from "cheerio"
|
|
|
|
import type { NewsItem } from "@shared/types"
|
|
|
|
|
|
|
|
export default defineSource(async () => {
|
2024-10-30 15:59:59 +08:00
|
|
|
const response: any = await myFetch("https://sputniknews.cn/services/widget/lenta/")
|
2024-10-09 03:23:19 +08:00
|
|
|
const $ = cheerio.load(response)
|
|
|
|
const $items = $(".lenta__item")
|
|
|
|
const news: NewsItem[] = []
|
|
|
|
$items.each((_, el) => {
|
|
|
|
const $el = $(el)
|
|
|
|
const $a = $el.find("a")
|
|
|
|
const url = $a.attr("href")
|
|
|
|
const title = $a.find(".lenta__item-text").text()
|
|
|
|
const date = $a.find(".lenta__item-date").attr("data-unixtime")
|
|
|
|
if (url && title && date) {
|
|
|
|
news.push({
|
2024-10-11 23:44:50 +08:00
|
|
|
url: `https://sputniknews.cn${url}`,
|
2024-10-09 03:23:19 +08:00
|
|
|
title,
|
|
|
|
id: url,
|
|
|
|
extra: {
|
|
|
|
date: new Date(Number(`${date}000`)).getTime(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2024-10-21 01:38:58 +08:00
|
|
|
return news
|
2024-10-09 03:23:19 +08:00
|
|
|
})
|