mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
feat: fetch sputniknewscn
This commit is contained in:
parent
ae81649d29
commit
9ecfc81dcb
@ -1,4 +1,5 @@
|
||||
import fs from "node:fs"
|
||||
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { join } from "node:path"
|
||||
import { Buffer } from "node:buffer"
|
||||
@ -27,7 +28,7 @@ async function main() {
|
||||
await Promise.all(
|
||||
Object.entries(originSources).map(async ([id, source]) => {
|
||||
try {
|
||||
const icon = join(iconsDir, `${id.split("-")[0]}.png`)
|
||||
const icon = join(iconsDir, `${id}.png`)
|
||||
if (fs.existsSync(icon)) {
|
||||
consola.info(`${id}: icon exists. skip.`)
|
||||
return
|
||||
|
@ -6,6 +6,7 @@ import ithome from "./ithome"
|
||||
import zhihu from "./zhihu"
|
||||
import cankaoxiaoxi from "./cankaoxiaoxi"
|
||||
import coolapk from "./coolapk"
|
||||
import sputniknewscn from "./sputniknewscn"
|
||||
|
||||
export const sourcesFn = {
|
||||
weibo,
|
||||
@ -15,10 +16,10 @@ export const sourcesFn = {
|
||||
zhihu,
|
||||
coolapk,
|
||||
cankaoxiaoxi,
|
||||
sputniknewscn,
|
||||
"peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", {
|
||||
hiddenDate: true,
|
||||
}),
|
||||
"sputniknewscn": defineRSSHubSource("/sputniknews/news/chinese"),
|
||||
"douyin": defineFallbackSource("douyin"),
|
||||
"aljazeeracn": defineRSSSource("https://feedx.net/rss/aljazeera.xml"),
|
||||
"toutiao": defineFallbackSource("toutiao"),
|
||||
|
28
server/sources/sputniknewscn.ts
Normal file
28
server/sources/sputniknewscn.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import * as cheerio from "cheerio"
|
||||
import type { NewsItem } from "@shared/types"
|
||||
import { $fetch } from "ofetch"
|
||||
|
||||
export default defineSource(async () => {
|
||||
const response = await $fetch("https://sputniknews.cn/services/widget/lenta/")
|
||||
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({
|
||||
url,
|
||||
title,
|
||||
id: url,
|
||||
extra: {
|
||||
date: new Date(Number(`${date}000`)).getTime(),
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
return news.slice(0, 20)
|
||||
})
|
@ -22,7 +22,6 @@ export const originSources = {
|
||||
},
|
||||
"sputniknewscn": {
|
||||
name: "俄罗斯卫星通讯社",
|
||||
interval: Time.half,
|
||||
home: "https://sputniknews.cn",
|
||||
},
|
||||
"aljazeeracn": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user