feat(source): add steam
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Vendored
+1
@@ -31,6 +31,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' {
|
||||
export const solidot: typeof import('./sources/solidot')
|
||||
export const sputniknewscn: typeof import('./sources/sputniknewscn')
|
||||
export const sspai: typeof import('./sources/sspai')
|
||||
export const steam: typeof import('./sources/steam')
|
||||
export const thepaper: typeof import('./sources/thepaper')
|
||||
export const tieba: typeof import('./sources/tieba')
|
||||
export const toutiao: typeof import('./sources/toutiao')
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import * as cheerio from "cheerio"
|
||||
import type { NewsItem } from "@shared/types"
|
||||
|
||||
export default defineSource(async () => {
|
||||
const response: any = await myFetch("https://store.steampowered.com/stats/stats/")
|
||||
const $ = cheerio.load(response)
|
||||
const $rows = $("#detailStats tr.player_count_row")
|
||||
const news: NewsItem[] = []
|
||||
|
||||
$rows.each((_, el) => {
|
||||
const $el = $(el)
|
||||
const $a = $el.find("a.gameLink")
|
||||
const url = $a.attr("href")
|
||||
const gameName = $a.text().trim()
|
||||
const currentPlayers = $el.find("td:first-child .currentServers").text().trim()
|
||||
|
||||
if (url && gameName && currentPlayers) {
|
||||
const title = gameName
|
||||
news.push({
|
||||
url,
|
||||
title,
|
||||
id: url,
|
||||
pubDate: Date.now(),
|
||||
extra: {
|
||||
info: currentPlayers,
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return news
|
||||
})
|
||||
+2
-1
@@ -42,5 +42,6 @@
|
||||
"ifeng": "fenghuangwang-redianzixun",
|
||||
"chongbuluo-latest": "chongbuluo-zuixin",
|
||||
"chongbuluo-hot": "chongbuluo-zuire",
|
||||
"douban": "douban-remendianying"
|
||||
"douban": "douban-remendianying",
|
||||
"steam": "Steam-zaixianrenshu"
|
||||
}
|
||||
@@ -421,6 +421,14 @@ export const originSources = {
|
||||
type: "hottest",
|
||||
home: "https://www.douban.com",
|
||||
},
|
||||
"steam": {
|
||||
name: "Steam",
|
||||
column: "world",
|
||||
title: "在线人数",
|
||||
color: "blue",
|
||||
type: "hottest",
|
||||
home: "https://store.steampowered.com",
|
||||
},
|
||||
} as const satisfies Record<string, OriginSource>
|
||||
|
||||
export function genSources() {
|
||||
|
||||
@@ -481,5 +481,14 @@
|
||||
"home": "https://www.douban.com",
|
||||
"color": "green",
|
||||
"interval": 600000
|
||||
},
|
||||
"steam": {
|
||||
"title": "在线人数",
|
||||
"name": "Steam",
|
||||
"type": "hottest",
|
||||
"column": "world",
|
||||
"home": "https://store.steampowered.com",
|
||||
"color": "blue",
|
||||
"interval": 600000
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user