mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 11:19: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 fs from "node:fs"
|
||||||
|
|
||||||
import { fileURLToPath } from "node:url"
|
import { fileURLToPath } from "node:url"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { Buffer } from "node:buffer"
|
import { Buffer } from "node:buffer"
|
||||||
@ -27,7 +28,7 @@ async function main() {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.entries(originSources).map(async ([id, source]) => {
|
Object.entries(originSources).map(async ([id, source]) => {
|
||||||
try {
|
try {
|
||||||
const icon = join(iconsDir, `${id.split("-")[0]}.png`)
|
const icon = join(iconsDir, `${id}.png`)
|
||||||
if (fs.existsSync(icon)) {
|
if (fs.existsSync(icon)) {
|
||||||
consola.info(`${id}: icon exists. skip.`)
|
consola.info(`${id}: icon exists. skip.`)
|
||||||
return
|
return
|
||||||
|
@ -6,6 +6,7 @@ import ithome from "./ithome"
|
|||||||
import zhihu from "./zhihu"
|
import zhihu from "./zhihu"
|
||||||
import cankaoxiaoxi from "./cankaoxiaoxi"
|
import cankaoxiaoxi from "./cankaoxiaoxi"
|
||||||
import coolapk from "./coolapk"
|
import coolapk from "./coolapk"
|
||||||
|
import sputniknewscn from "./sputniknewscn"
|
||||||
|
|
||||||
export const sourcesFn = {
|
export const sourcesFn = {
|
||||||
weibo,
|
weibo,
|
||||||
@ -15,10 +16,10 @@ export const sourcesFn = {
|
|||||||
zhihu,
|
zhihu,
|
||||||
coolapk,
|
coolapk,
|
||||||
cankaoxiaoxi,
|
cankaoxiaoxi,
|
||||||
|
sputniknewscn,
|
||||||
"peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", {
|
"peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", {
|
||||||
hiddenDate: true,
|
hiddenDate: true,
|
||||||
}),
|
}),
|
||||||
"sputniknewscn": defineRSSHubSource("/sputniknews/news/chinese"),
|
|
||||||
"douyin": defineFallbackSource("douyin"),
|
"douyin": defineFallbackSource("douyin"),
|
||||||
"aljazeeracn": defineRSSSource("https://feedx.net/rss/aljazeera.xml"),
|
"aljazeeracn": defineRSSSource("https://feedx.net/rss/aljazeera.xml"),
|
||||||
"toutiao": defineFallbackSource("toutiao"),
|
"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": {
|
"sputniknewscn": {
|
||||||
name: "俄罗斯卫星通讯社",
|
name: "俄罗斯卫星通讯社",
|
||||||
interval: Time.half,
|
|
||||||
home: "https://sputniknews.cn",
|
home: "https://sputniknews.cn",
|
||||||
},
|
},
|
||||||
"aljazeeracn": {
|
"aljazeeracn": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user