rsshub 1.0.0-master.ff3a9ce → 1.0.0-master.ff3ea5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.ts +38 -0
- package/lib/errors/index.tsx +3 -2
- package/lib/middleware/debug.ts +6 -4
- package/lib/middleware/header.ts +4 -2
- package/lib/registry.test.ts +24 -1
- package/lib/registry.ts +40 -11
- package/lib/router.js +1 -1
- package/lib/routes/121/namespace.ts +9 -0
- package/lib/routes/121/templates/description.art +17 -0
- package/lib/routes/121/weather-live.ts +104 -0
- package/lib/routes/141jav/index.ts +3 -0
- package/lib/routes/141ppv/index.ts +3 -0
- package/lib/routes/163/news/rank.ts +1 -1
- package/lib/routes/18comic/album.ts +59 -64
- package/lib/routes/18comic/index.ts +1 -0
- package/lib/routes/18comic/search.ts +53 -4
- package/lib/routes/18comic/utils.ts +70 -1
- package/lib/routes/2048/index.ts +1 -0
- package/lib/routes/30secondsofcode/utils.ts +0 -1
- package/lib/routes/6park/index.ts +1 -1
- package/lib/routes/7mmtv/index.ts +1 -0
- package/lib/routes/91porn/index.ts +1 -0
- package/lib/routes/95mm/tab.ts +1 -0
- package/lib/routes/agefans/detail.ts +1 -1
- package/lib/routes/aliyun/database-month.ts +1 -1
- package/lib/routes/anthropic/research.ts +112 -0
- package/lib/routes/apnews/topics.ts +2 -1
- package/lib/routes/apnews/utils.ts +1 -1
- package/lib/routes/apple/design.ts +54 -0
- package/lib/routes/apple/namespace.ts +1 -1
- package/lib/routes/aqara/post.ts +1 -1
- package/lib/routes/augmentcode/blog.ts +161 -0
- package/lib/routes/augmentcode/namespace.ts +9 -0
- package/lib/routes/augmentcode/templates/description.art +17 -0
- package/lib/routes/azul/namespace.ts +9 -0
- package/lib/routes/azul/packages.ts +105 -0
- package/lib/routes/banshujiang/index.ts +763 -0
- package/lib/routes/banshujiang/namespace.ts +9 -0
- package/lib/routes/banshujiang/templates/description.art +17 -0
- package/lib/routes/bfl/announcements.ts +1 -1
- package/lib/routes/bilibili/cache.ts +78 -0
- package/lib/routes/bilibili/danmaku.ts +1 -1
- package/lib/routes/bilibili/dynamic.ts +8 -2
- package/lib/routes/bilibili/video.ts +31 -73
- package/lib/routes/biquge/index.ts +1 -1
- package/lib/routes/bsky/keyword.ts +15 -10
- package/lib/routes/capitalmind/insights.ts +40 -0
- package/lib/routes/capitalmind/namespace.ts +8 -0
- package/lib/routes/capitalmind/podcasts.ts +41 -0
- package/lib/routes/capitalmind/utils.ts +122 -0
- package/lib/routes/cartoonmad/comic.ts +1 -1
- package/lib/routes/chikubi/index.ts +1 -0
- package/lib/routes/chikubi/tag.ts +1 -0
- package/lib/routes/chocolatey/namespace.ts +9 -0
- package/lib/routes/chocolatey/packages.ts +122 -0
- package/lib/routes/cmde/index.ts +1 -1
- package/lib/routes/cockroachlabs/blog.ts +113 -0
- package/lib/routes/cockroachlabs/namespace.ts +7 -0
- package/lib/routes/cool18/index.ts +4 -1
- package/lib/routes/coomer/index.ts +12 -6
- package/lib/routes/coomer/namespace.ts +1 -1
- package/lib/routes/copymanga/comic.ts +7 -9
- package/lib/routes/css-tricks/articles.ts +48 -0
- package/lib/routes/css-tricks/collections.ts +62 -0
- package/lib/routes/css-tricks/namespace.ts +8 -0
- package/lib/routes/css-tricks/popular.ts +39 -0
- package/lib/routes/css-tricks/utils.ts +103 -0
- package/lib/routes/cursor/changelog.ts +26 -17
- package/lib/routes/cursor/namespace.ts +1 -1
- package/lib/routes/cw/utils.ts +6 -13
- package/lib/routes/dealstreetasia/home.ts +1 -1
- package/lib/routes/dedao/index.ts +3 -3
- package/lib/routes/deepl/blog.ts +422 -0
- package/lib/routes/deepl/namespace.ts +9 -0
- package/lib/routes/deepl/templates/description.art +21 -0
- package/lib/routes/deeplearning/the-batch.ts +1 -1
- package/lib/routes/dev.to/guides.ts +100 -0
- package/lib/routes/dev.to/namespace.ts +8 -0
- package/lib/routes/dev.to/top.ts +105 -0
- package/lib/routes/dgut/jwb.ts +73 -0
- package/lib/routes/dgut/namespace.ts +9 -0
- package/lib/routes/digitalpolicyalert/activity-tracker.ts +135 -0
- package/lib/routes/digitalpolicyalert/namespace.ts +9 -0
- package/lib/routes/dnaindia/common.ts +26 -8
- package/lib/routes/douban/other/list.ts +3 -3
- package/lib/routes/e-hentai/index.ts +4 -1
- package/lib/routes/ehentai/tag.ts +1 -0
- package/lib/routes/englishhome/index.ts +55 -0
- package/lib/routes/englishhome/namespace.ts +6 -0
- package/lib/routes/epicgames/index.ts +2 -2
- package/lib/routes/espn/news.ts +1 -1
- package/lib/routes/expats/czech-news.ts +272 -0
- package/lib/routes/expats/namespace.ts +9 -0
- package/lib/routes/fanbox/index.ts +1 -0
- package/lib/routes/fanbox/utils.ts +1 -1
- package/lib/routes/fansly/tag.ts +1 -0
- package/lib/routes/fantia/search.ts +1 -1
- package/lib/routes/fantube/creator.ts +69 -0
- package/lib/routes/fantube/namespace.ts +7 -0
- package/lib/routes/fantube/templates/post.art +17 -0
- package/lib/routes/fantube/types.ts +100 -0
- package/lib/routes/fantube/utils.ts +268 -0
- package/lib/routes/follow/profile.ts +1 -1
- package/lib/routes/followin/news.ts +1 -1
- package/lib/routes/foresightnews/util.ts +1 -1
- package/lib/routes/freexcomic/book.ts +4 -1
- package/lib/routes/gamer/hot.ts +5 -5
- package/lib/routes/gaoyu/blog.ts +145 -0
- package/lib/routes/gaoyu/namespace.ts +9 -0
- package/lib/routes/gaoyu/templates/description.art +7 -0
- package/lib/routes/geocaching/blogs.ts +2 -2
- package/lib/routes/github/namespace.ts +1 -1
- package/lib/routes/github/private-feed.ts +229 -0
- package/lib/routes/github/star.ts +1 -1
- package/lib/routes/google/extension.ts +9 -10
- package/lib/routes/gov/beijing/bphc/index.ts +1 -1
- package/lib/routes/gov/ccdi/index.ts +1 -1
- package/lib/routes/gov/chongqing/sydwgkzp.ts +22 -6
- package/lib/routes/gov/customs/list.ts +1 -1
- package/lib/routes/gov/general/general.ts +1 -1
- package/lib/routes/gov/hangzhou/zwfw.ts +1 -1
- package/lib/routes/gov/pbc/goutongjiaoliu.ts +1 -1
- package/lib/routes/gov/shenzhen/szlh/index.ts +77 -0
- package/lib/routes/gov/shenzhen/szlh/namespace.ts +8 -0
- package/lib/routes/grist/utils.ts +5 -4
- package/lib/routes/hanime1/search.ts +4 -2
- package/lib/routes/hellogithub/report.ts +1 -1
- package/lib/routes/hit/hitgs.ts +240 -54
- package/lib/routes/hit/templates/description.art +7 -0
- package/lib/routes/hlju/namespace.ts +8 -0
- package/lib/routes/hlju/news.ts +141 -0
- package/lib/routes/hostmonit/cloudflareyes.ts +1 -1
- package/lib/routes/hotukdeals/index.ts +1 -1
- package/lib/routes/hyperdash/namespace.ts +7 -0
- package/lib/routes/hyperdash/templates/description.art +34 -0
- package/lib/routes/hyperdash/top-traders.ts +84 -0
- package/lib/routes/hyperdash/utils.ts +49 -0
- package/lib/routes/hypergryph/arknights/announce.ts +1 -1
- package/lib/routes/ielts/index.ts +1 -1
- package/lib/routes/infoq/topic.ts +16 -13
- package/lib/routes/instagram/web-api/index.ts +17 -13
- package/lib/routes/instagram/web-api/utils.ts +46 -63
- package/lib/routes/jamesclear/book-summaries.ts +40 -0
- package/lib/routes/jamesclear/great-speeches.ts +40 -0
- package/lib/routes/jamesclear/namespace.ts +8 -0
- package/lib/routes/jamesclear/quotes.ts +40 -0
- package/lib/routes/jamesclear/three-two-one.ts +41 -0
- package/lib/routes/jamesclear/utils.ts +22 -0
- package/lib/routes/japanpost/utils.ts +2 -2
- package/lib/routes/javbus/index.ts +3 -0
- package/lib/routes/javdb/tags.ts +1 -0
- package/lib/routes/javlibrary/star.ts +1 -0
- package/lib/routes/javtiful/actress.ts +3 -0
- package/lib/routes/javtiful/channel.ts +3 -0
- package/lib/routes/javtrailers/casts.ts +3 -0
- package/lib/routes/jetbrains/comments.ts +99 -0
- package/lib/routes/jetbrains/namespace.ts +8 -0
- package/lib/routes/jimmyspa/books.ts +1 -1
- package/lib/routes/jimmyspa/news.ts +1 -1
- package/lib/routes/jpxgmn/tab.ts +3 -0
- package/lib/routes/kakuyomu/works.ts +3 -0
- package/lib/routes/kaopu/news.ts +1 -1
- package/lib/routes/kemono/const.ts +1 -1
- package/lib/routes/kemono/index.ts +12 -11
- package/lib/routes/kemono/namespace.ts +1 -1
- package/lib/routes/kiro/blog.ts +131 -0
- package/lib/routes/kiro/changelog.ts +128 -0
- package/lib/routes/kiro/namespace.ts +9 -0
- package/lib/routes/konachan/post.ts +3 -0
- package/lib/routes/kovidgoyal/kitty/changelog.ts +83 -0
- package/lib/routes/kovidgoyal/namespace.ts +7 -0
- package/lib/routes/kunchengblog/essay.ts +1 -1
- package/lib/routes/landiannews/category.ts +1 -1
- package/lib/routes/landiannews/index.ts +1 -1
- package/lib/routes/landiannews/tag.ts +1 -1
- package/lib/routes/line/utils.ts +1 -1
- package/lib/routes/lineageos/changes.ts +79 -0
- package/lib/routes/lineageos/namespace.ts +9 -0
- package/lib/routes/linkedin/cn/renderer.ts +1 -1
- package/lib/routes/liquipedia/cs-matches.ts +42 -14
- package/lib/routes/literotica/new.ts +1 -0
- package/lib/routes/lofter/tag.ts +27 -3
- package/lib/routes/makerworld/contest.ts +51 -0
- package/lib/routes/makerworld/namespace.ts +7 -0
- package/lib/routes/makerworld/trending.ts +45 -0
- package/lib/routes/makerworld/user-upload.ts +54 -0
- package/lib/routes/makerworld/utils.ts +18 -0
- package/lib/routes/manhuagui/comic.ts +1 -1
- package/lib/routes/manus/blog.ts +77 -0
- package/lib/routes/manus/namespace.ts +7 -0
- package/lib/routes/mastodon/tag.ts +48 -0
- package/lib/routes/mathpix/blog.ts +155 -0
- package/lib/routes/mathpix/namespace.ts +9 -0
- package/lib/routes/mathpix/templates/description.art +21 -0
- package/lib/routes/mckinsey/cn/category-map.ts +9 -15
- package/lib/routes/mckinsey/cn/index.ts +77 -40
- package/lib/routes/melonbooks/search.ts +1 -0
- package/lib/routes/metacritic/index.ts +2 -2
- package/lib/routes/meteoblue/namespace.ts +8 -0
- package/lib/routes/meteoblue/weathernews.ts +75 -0
- package/lib/routes/meteor/index.ts +1 -1
- package/lib/routes/microsoft/addon.ts +7 -9
- package/lib/routes/mihoyo/zzz/news.ts +106 -0
- package/lib/routes/missav/new.ts +2 -1
- package/lib/routes/mit/hanlab.ts +61 -0
- package/lib/routes/mit/namespace.ts +6 -0
- package/lib/routes/mittrchina/index.ts +3 -3
- package/lib/routes/mixcloud/config.ts +129 -0
- package/lib/routes/mixcloud/index.ts +163 -107
- package/lib/routes/mixcloud/user-playlist.ts +31 -0
- package/lib/routes/mixi2/community.ts +72 -0
- package/lib/routes/mixi2/discovery.ts +52 -0
- package/lib/routes/mixi2/home.ts +51 -0
- package/lib/routes/mixi2/namespace.ts +8 -0
- package/lib/routes/mixi2/user.ts +77 -0
- package/lib/routes/mixi2/utils.ts +56 -0
- package/lib/routes/modelscope/learn.ts +94 -0
- package/lib/routes/moodysmismicrosite/report.ts +1 -1
- package/lib/routes/musify/index.ts +130 -0
- package/lib/routes/musify/namespace.ts +9 -0
- package/lib/routes/musikguru/namespace.ts +9 -0
- package/lib/routes/musikguru/news.ts +146 -0
- package/lib/routes/musikguru/templates/description.art +21 -0
- package/lib/routes/myfans/post.ts +1 -0
- package/lib/routes/nankai/cc-notice.ts +114 -0
- package/lib/routes/nankai/jwc.ts +131 -0
- package/lib/routes/nankai/namespace.ts +7 -0
- package/lib/routes/nankai/notice.ts +84 -0
- package/lib/routes/nankai/yzb.ts +97 -0
- package/lib/routes/neu/yz.ts +172 -0
- package/lib/routes/newslaundry/explainer.ts +30 -0
- package/lib/routes/newslaundry/namespace.ts +8 -0
- package/lib/routes/newslaundry/nl-cheatsheet.ts +30 -0
- package/lib/routes/newslaundry/nl-collaborations.ts +30 -0
- package/lib/routes/newslaundry/podcast.ts +61 -0
- package/lib/routes/newslaundry/reports.ts +30 -0
- package/lib/routes/newslaundry/shot.ts +30 -0
- package/lib/routes/newslaundry/subscriber-only.ts +30 -0
- package/lib/routes/newslaundry/templates/description.art +28 -0
- package/lib/routes/newslaundry/utils.ts +108 -0
- package/lib/routes/newswav/latest.ts +100 -0
- package/lib/routes/newswav/namespace.ts +7 -0
- package/lib/routes/nhentai/index.ts +1 -0
- package/lib/routes/nifd/research.ts +16 -0
- package/lib/routes/nio/namespace.ts +9 -0
- package/lib/routes/nio/nioradio.ts +75 -0
- package/lib/routes/njust/cs.ts +58 -0
- package/lib/routes/njust/utils.ts +1 -1
- package/lib/routes/ntdm/video.ts +1 -1
- package/lib/routes/nuaa/utils/pypasswaf.ts +1 -1
- package/lib/routes/oilchem/index.ts +1 -1
- package/lib/routes/oncc/money18.ts +1 -1
- package/lib/routes/openai/cookbook.ts +1 -1
- package/lib/routes/paulgraham/article.ts +2 -2
- package/lib/routes/picuki/profile.ts +4 -0
- package/lib/routes/pixiv/bookmarks.ts +1 -1
- package/lib/routes/pixiv/novel-api/series/sfw.ts +1 -1
- package/lib/routes/pixiv/novels.ts +2 -2
- package/lib/routes/pixiv/user.ts +1 -1
- package/lib/routes/playno1/av.ts +1 -0
- package/lib/routes/pornhub/model.ts +3 -7
- package/lib/routes/pornhub/pornstar.ts +2 -7
- package/lib/routes/pornhub/users.ts +2 -7
- package/lib/routes/pornhub/utils.ts +12 -1
- package/lib/routes/qingting/podcast.ts +2 -1
- package/lib/routes/qipamaijia/index.ts +1 -0
- package/lib/routes/questmobile/report.ts +1 -1
- package/lib/routes/railway/index.ts +73 -0
- package/lib/routes/railway/namespace.ts +8 -0
- package/lib/routes/reuters/common.ts +0 -3
- package/lib/routes/rockthejvm/articles.ts +167 -0
- package/lib/routes/rockthejvm/namespace.ts +9 -0
- package/lib/routes/rockthejvm/templates/description.art +7 -0
- package/lib/routes/samrdprc/namespace.ts +7 -0
- package/lib/routes/samrdprc/news.ts +79 -0
- package/lib/routes/sankei/namespace.ts +7 -0
- package/lib/routes/sankei/news.ts +68 -0
- package/lib/routes/sankei/topics.ts +71 -0
- package/lib/routes/sciencenet/user.ts +1 -1
- package/lib/routes/scoop/apps.ts +188 -0
- package/lib/routes/scoop/namespace.ts +9 -0
- package/lib/routes/scoop/templates/description.art +56 -0
- package/lib/routes/scpta/namespace.ts +8 -0
- package/lib/routes/scpta/news.ts +101 -0
- package/lib/routes/seekingalpha/index.ts +1 -1
- package/lib/routes/sehuatang/index.ts +29 -31
- package/lib/routes/setn/index.ts +11 -2
- package/lib/routes/seu/cyber/index.ts +78 -0
- package/lib/routes/sicau/jiaowu.ts +42 -34
- package/lib/routes/sis001/forum.ts +1 -0
- package/lib/routes/sjtu/seiee/icisee.ts +67 -0
- package/lib/routes/sketis/isabelle-dev/blog/index.ts +1 -1
- package/lib/routes/smartlink/index.ts +13 -3
- package/lib/routes/sohu/mp.ts +17 -6
- package/lib/routes/sotwe/namespace.ts +1 -0
- package/lib/routes/sotwe/user.ts +98 -0
- package/lib/routes/spankbang/new-videos.ts +1 -0
- package/lib/routes/spglobal/ratings.ts +1 -1
- package/lib/routes/stanford/blog.ts +77 -0
- package/lib/routes/stanford/namespace.ts +7 -0
- package/lib/routes/syosetu/index.ts +1 -1
- package/lib/routes/t66y/index.ts +1 -0
- package/lib/routes/taobao/mysql.ts +157 -0
- package/lib/routes/taobao/namespace.ts +2 -2
- package/lib/routes/techcrunch/category.ts +48 -0
- package/lib/routes/telegram/channel.ts +2 -2
- package/lib/routes/tesla/cx.ts +1 -1
- package/lib/routes/test/index.ts +1 -1
- package/lib/routes/themoviedb/episodes.ts +1 -1
- package/lib/routes/thewirehindi/category.ts +78 -0
- package/lib/routes/thewirehindi/index.ts +43 -0
- package/lib/routes/thewirehindi/namespace.ts +7 -0
- package/lib/routes/thewirehindi/templates/description.art +9 -0
- package/lib/routes/thewirehindi/utils.ts +33 -0
- package/lib/routes/threads/utils.ts +2 -2
- package/lib/routes/tidb/blog.ts +314 -0
- package/lib/routes/tidb/namespace.ts +9 -0
- package/lib/routes/tumblr/namespace.ts +17 -0
- package/lib/routes/tumblr/posts.ts +74 -0
- package/lib/routes/tumblr/utils.ts +110 -0
- package/lib/routes/tver/namespace.ts +7 -0
- package/lib/routes/tver/series.ts +98 -0
- package/lib/routes/twitter/api/web-api/login.ts +1 -3
- package/lib/routes/twitter/api/web-api/utils.ts +23 -1
- package/lib/routes/twitter/utils.ts +21 -21
- package/lib/routes/udn/breaking-news.ts +2 -2
- package/lib/routes/uestc/auto.ts +1 -1
- package/lib/routes/uestc/cqe.ts +1 -1
- package/lib/routes/uestc/scse.ts +1 -1
- package/lib/routes/uestc/sice.ts +1 -1
- package/lib/routes/uestc/sise.ts +1 -1
- package/lib/routes/upc/jwc.ts +32 -46
- package/lib/routes/uptimerobot/rss.ts +1 -1
- package/lib/routes/visionias/daily-news-summary.ts +65 -0
- package/lib/routes/visionias/monthly-magazine.ts +68 -0
- package/lib/routes/visionias/news-today.ts +3 -13
- package/lib/routes/visionias/utils.ts +5 -5
- package/lib/routes/visionias/weekly-focus.ts +2 -2
- package/lib/routes/wdfxw/bookfree.ts +528 -0
- package/lib/routes/wdfxw/namespace.ts +8 -0
- package/lib/routes/wdfxw/templates/description.art +13 -0
- package/lib/routes/whu/swrh.ts +1 -1
- package/lib/routes/windsurf/blog.ts +118 -0
- package/lib/routes/windsurf/changelog.ts +100 -0
- package/lib/routes/windsurf/namespace.ts +9 -0
- package/lib/routes/windsurf/templates/description.art +21 -0
- package/lib/routes/x6d/index.ts +1 -1
- package/lib/routes/xbookcn/blog.ts +1 -0
- package/lib/routes/xiaohongshu/util.ts +1 -3
- package/lib/routes/xiaoyuzhou/pickup.ts +1 -1
- package/lib/routes/ximalaya/album.ts +32 -70
- package/lib/routes/ximalaya/types.ts +48 -0
- package/lib/routes/ximalaya/utils.ts +9 -7
- package/lib/routes/xmanhua/index.ts +1 -0
- package/lib/routes/xueqiu/cookies.ts +1 -1
- package/lib/routes/xueqiu/user.ts +1 -1
- package/lib/routes/xwenming/index.ts +184 -0
- package/lib/routes/xwenming/namespace.ts +9 -0
- package/lib/routes/yahoo/news/utils.ts +1 -1
- package/lib/routes/yande/post.ts +3 -0
- package/lib/routes/ymgal/game.ts +1 -0
- package/lib/routes/youtube/api/google.ts +27 -0
- package/lib/routes/youtube/api/youtubei.ts +70 -20
- package/lib/routes/youtube/community.ts +3 -1
- package/lib/routes/youtube/utils.ts +16 -14
- package/lib/routes/zaobao/util.ts +8 -5
- package/lib/routes/zhihu/activities.ts +3 -0
- package/lib/routes/zhihu/execlib/x-zse-96-v3.ts +5 -5
- package/lib/routes/zhizhuan100/namespace.ts +7 -0
- package/lib/routes/zhizhuan100/report.ts +79 -0
- package/lib/routes/zimuxia/portfolio.ts +1 -1
- package/lib/routes/zju/sis/index.ts +161 -0
- package/lib/server.ts +5 -0
- package/lib/types.ts +58 -54
- package/lib/utils/helpers.ts +1 -1
- package/lib/utils/logger.ts +1 -1
- package/lib/utils/proxy/index.ts +102 -18
- package/lib/utils/proxy/multi-proxy.ts +139 -0
- package/lib/utils/proxy/unify-proxy.ts +3 -1
- package/lib/utils/puppeteer-utils.test.ts +1 -1
- package/lib/utils/puppeteer.test.ts +14 -27
- package/lib/utils/puppeteer.ts +51 -37
- package/lib/utils/readable-social.test.ts +65 -0
- package/lib/utils/readable-social.ts +15 -1
- package/lib/utils/request-rewriter/fetch.ts +42 -4
- package/package.json +54 -56
- package/lib/routes/mixcloud/queries.ts +0 -2274
- package/lib/routes-deprecated/dev.to/top.js +0 -40
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type Data, type DataItem, type Route, ViewType } from '@/types';
|
|
2
|
+
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
|
+
import { parseDate } from '@/utils/parse-date';
|
|
5
|
+
|
|
6
|
+
import { type CheerioAPI, type Cheerio, load } from 'cheerio';
|
|
7
|
+
import type { Element } from 'domhandler';
|
|
8
|
+
import { type Context } from 'hono';
|
|
9
|
+
|
|
10
|
+
export const handler = async (ctx: Context): Promise<Data> => {
|
|
11
|
+
const { id } = ctx.req.param();
|
|
12
|
+
|
|
13
|
+
const baseUrl: string = 'https://community.chocolatey.org';
|
|
14
|
+
const targetUrl: string = new URL(`packages/${id}`, baseUrl).href;
|
|
15
|
+
|
|
16
|
+
const response = await ofetch(targetUrl);
|
|
17
|
+
const $: CheerioAPI = load(response);
|
|
18
|
+
const language = $('html').attr('lang') ?? 'en';
|
|
19
|
+
|
|
20
|
+
const title: string = $('meta[property="og:title"]').attr('content');
|
|
21
|
+
const description: string | undefined = $('div#description').html();
|
|
22
|
+
const pubDateStr: string | undefined = $('h3.mt-0.mb-3').last().text();
|
|
23
|
+
const categoryEls: Element[] = $('a[data-package-tag]').toArray();
|
|
24
|
+
const categories: string[] = [...new Set(categoryEls.map((el) => $(el).text()).filter(Boolean))];
|
|
25
|
+
const authorEls: Element[] = $('img[alt="gravatar"]').toArray();
|
|
26
|
+
const authors: DataItem['author'] = authorEls.map((authorEl) => {
|
|
27
|
+
const $authorEl: Cheerio<Element> = $(authorEl).parent();
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
name: $authorEl.find('span').text(),
|
|
31
|
+
url: $authorEl.attr('href') ? new URL($authorEl.attr('href') as string, baseUrl).href : undefined,
|
|
32
|
+
avatar: $authorEl.attr('src'),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const guid: string = `chocolatey-${title}`;
|
|
36
|
+
const image: string | undefined = $('div.package-logo img').attr('src') ? new URL($('div.package-logo img').attr('src') as string, baseUrl).href : undefined;
|
|
37
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
38
|
+
|
|
39
|
+
const processedItem: DataItem = {
|
|
40
|
+
title,
|
|
41
|
+
description,
|
|
42
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : undefined,
|
|
43
|
+
link: targetUrl,
|
|
44
|
+
category: categories,
|
|
45
|
+
author: authors,
|
|
46
|
+
guid,
|
|
47
|
+
id: guid,
|
|
48
|
+
content: {
|
|
49
|
+
html: description,
|
|
50
|
+
text: description,
|
|
51
|
+
},
|
|
52
|
+
image,
|
|
53
|
+
banner: image,
|
|
54
|
+
updated: upDatedStr ? parseDate(upDatedStr) : undefined,
|
|
55
|
+
language,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const items: DataItem[] = [processedItem];
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
title: $('title').first().text(),
|
|
62
|
+
description: $('meta[property="og:description"]').attr('content'),
|
|
63
|
+
link: targetUrl,
|
|
64
|
+
item: items,
|
|
65
|
+
allowEmpty: true,
|
|
66
|
+
image: $('meta[property="og:image"]').attr('content'),
|
|
67
|
+
author: $('meta[property="og:site_name"]').attr('content'),
|
|
68
|
+
language,
|
|
69
|
+
id: $('meta[property="og:url"]').attr('content'),
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const route: Route = {
|
|
74
|
+
path: '/packages/:id',
|
|
75
|
+
name: 'Package',
|
|
76
|
+
url: 'community.chocolatey.org',
|
|
77
|
+
maintainers: ['nczitzk'],
|
|
78
|
+
handler,
|
|
79
|
+
example: '/chocolatey/packages/microsoft-edge',
|
|
80
|
+
parameters: {
|
|
81
|
+
id: {
|
|
82
|
+
description: 'Package ID',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
description: undefined,
|
|
86
|
+
categories: ['program-update'],
|
|
87
|
+
features: {
|
|
88
|
+
requireConfig: false,
|
|
89
|
+
requirePuppeteer: false,
|
|
90
|
+
antiCrawler: false,
|
|
91
|
+
supportRadar: true,
|
|
92
|
+
supportBT: false,
|
|
93
|
+
supportPodcast: false,
|
|
94
|
+
supportScihub: false,
|
|
95
|
+
},
|
|
96
|
+
radar: [
|
|
97
|
+
{
|
|
98
|
+
source: ['community.chocolatey.org/packages'],
|
|
99
|
+
target: (params) => {
|
|
100
|
+
const id: string = params.id;
|
|
101
|
+
|
|
102
|
+
return `/chocolatey/package${id ? `/${id}` : ''}`;
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
view: ViewType.Notifications,
|
|
107
|
+
|
|
108
|
+
zh: {
|
|
109
|
+
path: '/packages/:id',
|
|
110
|
+
name: '程序包',
|
|
111
|
+
url: 'community.chocolatey.org',
|
|
112
|
+
maintainers: ['nczitzk'],
|
|
113
|
+
handler,
|
|
114
|
+
example: '/chocolatey/package/microsoft-edge',
|
|
115
|
+
parameters: {
|
|
116
|
+
id: {
|
|
117
|
+
description: '程序包 ID',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
description: undefined,
|
|
121
|
+
},
|
|
122
|
+
};
|
package/lib/routes/cmde/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export const route: Route = {
|
|
|
17
17
|
async function handler(ctx) {
|
|
18
18
|
const cate = ctx.req.param('cate') ?? 'xwdt/zxyw';
|
|
19
19
|
const url = `${rootURL}/${cate}/`;
|
|
20
|
-
const browser = await puppeteer(
|
|
20
|
+
const browser = await puppeteer();
|
|
21
21
|
const data = await cache.tryGet(url, async () => {
|
|
22
22
|
const page = await browser.newPage();
|
|
23
23
|
await page.setRequestInterception(true);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import { load } from 'cheerio';
|
|
4
|
+
import cache from '@/utils/cache';
|
|
5
|
+
import { parseDate } from '@/utils/parse-date';
|
|
6
|
+
|
|
7
|
+
export const route: Route = {
|
|
8
|
+
name: 'Blogs',
|
|
9
|
+
maintainers: ['CookiePieWw'],
|
|
10
|
+
categories: ['programming'],
|
|
11
|
+
path: '/blog/:category?',
|
|
12
|
+
example: '/cockroachlabs/blog/engineering',
|
|
13
|
+
parameters: { category: 'Blog category, e.g., engineering. Subscribe all recent articles if empty.' },
|
|
14
|
+
features: {
|
|
15
|
+
requireConfig: false,
|
|
16
|
+
requirePuppeteer: false,
|
|
17
|
+
antiCrawler: false,
|
|
18
|
+
supportBT: false,
|
|
19
|
+
supportPodcast: false,
|
|
20
|
+
supportScihub: false,
|
|
21
|
+
},
|
|
22
|
+
radar: [
|
|
23
|
+
{
|
|
24
|
+
source: ['cockroachlabs.com/blog/:category', 'cockroachlabs.com/blog'],
|
|
25
|
+
target: '/blog',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
handler,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
async function handler(ctx) {
|
|
32
|
+
const category = ctx.req.param('category');
|
|
33
|
+
const rootUrl = 'https://www.cockroachlabs.com';
|
|
34
|
+
const currentUrl = `${rootUrl}/blog${category ? `/${category}/` : '/'}`;
|
|
35
|
+
|
|
36
|
+
const webpage = await ofetch(currentUrl);
|
|
37
|
+
const html = load(webpage);
|
|
38
|
+
|
|
39
|
+
// Title article:
|
|
40
|
+
// <a href="href..">
|
|
41
|
+
// <h2 class="mb-3 truncate text-display-md font-semibold tracking-tight md:max-w-full md:text-white">
|
|
42
|
+
// Title...
|
|
43
|
+
// </h2>
|
|
44
|
+
// </a>
|
|
45
|
+
const titleH2Element = html('[class="mb-3 truncate text-display-md font-semibold tracking-tight md:max-w-full md:text-white"]');
|
|
46
|
+
|
|
47
|
+
// Left articles:
|
|
48
|
+
// <a href="href..">
|
|
49
|
+
// <p class="mb-2 line-clamp-2 text-lg font-semibold leading-5">
|
|
50
|
+
// Title..
|
|
51
|
+
// </p>
|
|
52
|
+
// </a>
|
|
53
|
+
const leftArticles = html('a > p[class="mb-2 line-clamp-2 text-lg font-semibold leading-5"]');
|
|
54
|
+
const articleList = titleH2Element.add(leftArticles).map((_, element) => {
|
|
55
|
+
const title = html(element).text();
|
|
56
|
+
const link = `${rootUrl}${html(element).parent('a').attr('href')}`;
|
|
57
|
+
return { title, link };
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const items = await Promise.all(
|
|
61
|
+
articleList.toArray().map((article) =>
|
|
62
|
+
cache.tryGet(article.link, async () => {
|
|
63
|
+
const response = await ofetch(article.link);
|
|
64
|
+
const $ = load(response);
|
|
65
|
+
|
|
66
|
+
// <article class="blog-content null">
|
|
67
|
+
// ..multiple <div>/<a>/<img>/<p>..
|
|
68
|
+
// </article>
|
|
69
|
+
const content = $('article.blog-content').html() || '';
|
|
70
|
+
|
|
71
|
+
// <div class="mt-4 flex flex-col items-center justify-center gap-1 sm:flex-row sm:gap-4">
|
|
72
|
+
// <div>
|
|
73
|
+
// <p>
|
|
74
|
+
// Last edited on June 13, 2025
|
|
75
|
+
// </p>
|
|
76
|
+
// </div>
|
|
77
|
+
// ...
|
|
78
|
+
// </div>
|
|
79
|
+
const dateText = $(String.raw`div.mt-4.flex.flex-col.items-center.justify-center.gap-1.sm\:flex-row.sm\:gap-4`)
|
|
80
|
+
.find('p')
|
|
81
|
+
.first()
|
|
82
|
+
.text()
|
|
83
|
+
.match(/Last edited on (.+)/)?.[1];
|
|
84
|
+
|
|
85
|
+
let pubDate: Date | undefined;
|
|
86
|
+
if (dateText) {
|
|
87
|
+
try {
|
|
88
|
+
const date = new Date(dateText);
|
|
89
|
+
if (!Number.isNaN(date.getTime())) {
|
|
90
|
+
pubDate = parseDate(date.toISOString().split('T')[0]);
|
|
91
|
+
}
|
|
92
|
+
} catch {
|
|
93
|
+
// Ignore parsing errors
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
title: article.title,
|
|
99
|
+
link: article.link,
|
|
100
|
+
description: content,
|
|
101
|
+
pubDate,
|
|
102
|
+
};
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
title: `Cockroach Labs Blog${category ? ` - ${category}` : ''}`,
|
|
109
|
+
link: currentUrl,
|
|
110
|
+
item: items,
|
|
111
|
+
description: 'Cockroach Labs Blog',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -33,13 +33,16 @@ export const route: Route = {
|
|
|
33
33
|
name: '禁忌书屋',
|
|
34
34
|
maintainers: ['nczitzk', 'Gabrlie'],
|
|
35
35
|
handler,
|
|
36
|
+
features: {
|
|
37
|
+
nsfw: true,
|
|
38
|
+
},
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
async function handler(ctx: Context) {
|
|
39
42
|
const { id = 'bbs4', type = 'home', keyword } = ctx.req.param();
|
|
40
43
|
|
|
41
44
|
const rootUrl = 'https://www.cool18.com/' + id + '/index.php';
|
|
42
|
-
const params = type === 'home' ? '' :
|
|
45
|
+
const params = type === 'home' ? '' : type === 'gold' ? '?app=forum&act=gold' : `?action=search&act=threadsearch&app=forum&keywords=${keyword}&submit=查询`;
|
|
43
46
|
|
|
44
47
|
const currentUrl = rootUrl + params;
|
|
45
48
|
|
|
@@ -18,10 +18,16 @@ export const route: Route = {
|
|
|
18
18
|
supportBT: false,
|
|
19
19
|
supportPodcast: false,
|
|
20
20
|
supportScihub: false,
|
|
21
|
+
nsfw: true,
|
|
21
22
|
},
|
|
22
23
|
radar: [
|
|
23
24
|
{
|
|
24
|
-
source: ['coomer.
|
|
25
|
+
source: ['coomer.st/'],
|
|
26
|
+
target: '',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
source: ['coomer.st/:source/user/:id'],
|
|
30
|
+
target: '/:source/:id',
|
|
25
31
|
},
|
|
26
32
|
],
|
|
27
33
|
name: 'Posts',
|
|
@@ -45,9 +51,9 @@ async function handler(ctx) {
|
|
|
45
51
|
const id = ctx.req.param('id');
|
|
46
52
|
const isPosts = source === 'posts';
|
|
47
53
|
|
|
48
|
-
const rootUrl = 'https://coomer.
|
|
54
|
+
const rootUrl = 'https://coomer.st';
|
|
49
55
|
const apiUrl = `${rootUrl}/api/v1`;
|
|
50
|
-
const currentUrl = isPosts ? `${apiUrl}/posts` : `${apiUrl}/${source}/user/${id}`;
|
|
56
|
+
const currentUrl = isPosts ? `${apiUrl}/posts` : `${apiUrl}/${source}/user/${id}/posts`;
|
|
51
57
|
|
|
52
58
|
const headers = {
|
|
53
59
|
cookie: '__ddg2=sBQ4uaaGecmfEUk7',
|
|
@@ -60,9 +66,9 @@ async function handler(ctx) {
|
|
|
60
66
|
});
|
|
61
67
|
const responseData = isPosts ? response.data.posts : response.data;
|
|
62
68
|
|
|
63
|
-
const author = isPosts ? '' : await getAuthor(
|
|
69
|
+
const author = isPosts ? '' : await getAuthor(`${apiUrl}/${source}/user/${id}`, headers);
|
|
64
70
|
const title = isPosts ? 'Coomer Posts' : `Posts of ${author} from ${source} | Coomer`;
|
|
65
|
-
const image = isPosts ? `${rootUrl}/favicon.ico` : `https://img.coomer.
|
|
71
|
+
const image = isPosts ? `${rootUrl}/favicon.ico` : `https://img.coomer.st/icons/${source}/${id}`;
|
|
66
72
|
const items = responseData
|
|
67
73
|
.filter((i) => i.content || i.attachments)
|
|
68
74
|
.slice(0, limit)
|
|
@@ -131,7 +137,7 @@ async function handler(ctx) {
|
|
|
131
137
|
description: desc,
|
|
132
138
|
author,
|
|
133
139
|
pubDate: parseDate(i.published),
|
|
134
|
-
guid:
|
|
140
|
+
guid: `coomer:${i.service}:${i.user}:post:${i.id}`,
|
|
135
141
|
link: `${rootUrl}/${i.service}/user/${i.user}/post/${i.id}`,
|
|
136
142
|
...enclosureInfo,
|
|
137
143
|
};
|
|
@@ -2,7 +2,7 @@ import { Route } from '@/types';
|
|
|
2
2
|
|
|
3
3
|
import cache from '@/utils/cache';
|
|
4
4
|
import { load } from 'cheerio';
|
|
5
|
-
import
|
|
5
|
+
import ofetch from '@/utils/ofetch';
|
|
6
6
|
import { parseDate } from '@/utils/parse-date';
|
|
7
7
|
import { art } from '@/utils/render';
|
|
8
8
|
import path from 'node:path';
|
|
@@ -48,11 +48,11 @@ async function handler(ctx) {
|
|
|
48
48
|
do {
|
|
49
49
|
bHasNextPage = false;
|
|
50
50
|
// eslint-disable-next-line no-await-in-loop
|
|
51
|
-
const
|
|
51
|
+
const data = await ofetch(strBaseUrl, {
|
|
52
52
|
headers: {
|
|
53
|
-
platform:
|
|
53
|
+
platform: '',
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
query: {
|
|
56
56
|
limit: iReqLimit,
|
|
57
57
|
offset: iReqOffSet,
|
|
58
58
|
},
|
|
@@ -92,7 +92,7 @@ async function handler(ctx) {
|
|
|
92
92
|
|
|
93
93
|
// 获取漫画标题、介绍
|
|
94
94
|
const { bookTitle, bookIntro } = await cache.tryGet(`${baseUrl}/comic/${id}`, async () => {
|
|
95
|
-
const
|
|
95
|
+
const data = await ofetch(`${baseUrl}/comic/${id}`);
|
|
96
96
|
const $ = load(data);
|
|
97
97
|
return {
|
|
98
98
|
bookTitle: $('.comicParticulars-title-right > ul > li > h6').text(),
|
|
@@ -101,11 +101,9 @@ async function handler(ctx) {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
const genResult = async (chapter) => {
|
|
104
|
-
const {
|
|
105
|
-
data: { code, results },
|
|
106
|
-
} = await got(`${apiBaseUrl}/api/v3/comic/${id}/chapter/${chapter.uuid}`, {
|
|
104
|
+
const { code, results } = await ofetch(`${apiBaseUrl}/api/v3/comic/${id}/chapter/${chapter.uuid}`, {
|
|
107
105
|
headers: {
|
|
108
|
-
webp: 1,
|
|
106
|
+
webp: '1',
|
|
109
107
|
},
|
|
110
108
|
});
|
|
111
109
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Data, Route, ViewType } from '@/types';
|
|
2
|
+
import { load } from 'cheerio';
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
|
+
import { processWithWp } from './utils';
|
|
5
|
+
export const route: Route = {
|
|
6
|
+
path: '/articles',
|
|
7
|
+
view: ViewType.Articles,
|
|
8
|
+
categories: ['programming'],
|
|
9
|
+
example: '/css-tricks/articles',
|
|
10
|
+
features: {
|
|
11
|
+
requireConfig: false,
|
|
12
|
+
requirePuppeteer: false,
|
|
13
|
+
antiCrawler: false,
|
|
14
|
+
supportBT: false,
|
|
15
|
+
supportPodcast: false,
|
|
16
|
+
supportScihub: false,
|
|
17
|
+
},
|
|
18
|
+
radar: [
|
|
19
|
+
{
|
|
20
|
+
source: ['css-tricks.com/category/articles/'],
|
|
21
|
+
target: '/articles',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
name: 'Articles',
|
|
25
|
+
maintainers: ['Rjnishant530'],
|
|
26
|
+
handler,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
async function handler() {
|
|
30
|
+
// const category = ctx.req.param('category') ?? '';
|
|
31
|
+
// const subCategory = ctx.req.param('subCategory') ?? '';
|
|
32
|
+
|
|
33
|
+
const rootUrl = 'https://css-tricks.com';
|
|
34
|
+
const currentUrl = `${rootUrl}/category/articles/`;
|
|
35
|
+
const response = await ofetch(currentUrl);
|
|
36
|
+
const $ = load(response);
|
|
37
|
+
const articleCards = $('article.article-card').toArray();
|
|
38
|
+
const items = await processWithWp(articleCards);
|
|
39
|
+
return {
|
|
40
|
+
title: 'Articles - CSS-Tricks',
|
|
41
|
+
description: 'Latest Articles - CSS-Tricks',
|
|
42
|
+
link: currentUrl,
|
|
43
|
+
item: items,
|
|
44
|
+
language: 'en',
|
|
45
|
+
logo: `${rootUrl}/favicon.ico`,
|
|
46
|
+
icon: `${rootUrl}/favicon.ico`,
|
|
47
|
+
} as Data;
|
|
48
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Data, Route, ViewType } from '@/types';
|
|
2
|
+
import { extractMiniCards, processWithWp, rootUrl } from './utils';
|
|
3
|
+
export const route: Route = {
|
|
4
|
+
path: '/collections/:type',
|
|
5
|
+
view: ViewType.Articles,
|
|
6
|
+
categories: ['programming'],
|
|
7
|
+
example: '/css-tricks/collections/2',
|
|
8
|
+
parameters: {
|
|
9
|
+
category: {
|
|
10
|
+
description: 'Collection Type',
|
|
11
|
+
options: [
|
|
12
|
+
{ value: '3', label: 'Latest CSS Guides' },
|
|
13
|
+
{ value: '2', label: 'Fresh From the Almanac' },
|
|
14
|
+
{ value: '4', label: 'Classic Tricks' },
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
features: {
|
|
19
|
+
requireConfig: false,
|
|
20
|
+
requirePuppeteer: false,
|
|
21
|
+
antiCrawler: false,
|
|
22
|
+
supportBT: false,
|
|
23
|
+
supportPodcast: false,
|
|
24
|
+
supportScihub: false,
|
|
25
|
+
},
|
|
26
|
+
radar: [
|
|
27
|
+
{
|
|
28
|
+
source: ['css-tricks.com'],
|
|
29
|
+
target: '/collections/:type',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
name: 'CSS Guides',
|
|
33
|
+
maintainers: ['Rjnishant530'],
|
|
34
|
+
handler,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const WPTYPE = {
|
|
38
|
+
'2': 'pages',
|
|
39
|
+
'3': 'posts',
|
|
40
|
+
'4': 'chapters',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
async function handler(ctx) {
|
|
44
|
+
const paramType = ctx.req.param('type');
|
|
45
|
+
const type = paramType === '1' ? '2' : paramType;
|
|
46
|
+
const baseSelector = `body > div.page-wrap > section.post-sliders > div:nth-child(${type})`;
|
|
47
|
+
const titleSelector = `${baseSelector}>div.post-slider-header.header-card > h2`;
|
|
48
|
+
const descSelector = `${baseSelector}>div.post-slider-header.header-card > p`;
|
|
49
|
+
const cardselector = `${baseSelector} article.mini-card.module.module-article`;
|
|
50
|
+
|
|
51
|
+
const { title, description, cards } = await extractMiniCards(cardselector, titleSelector, descSelector);
|
|
52
|
+
const items = await processWithWp(cards, true, WPTYPE[type]);
|
|
53
|
+
return {
|
|
54
|
+
title: title || 'Fresh From the Almanac',
|
|
55
|
+
description: description || 'Properties, selectors, rules, and functions!',
|
|
56
|
+
link: rootUrl,
|
|
57
|
+
item: items,
|
|
58
|
+
language: 'en',
|
|
59
|
+
logo: `${rootUrl}/favicon.ico`,
|
|
60
|
+
icon: `${rootUrl}/favicon.ico`,
|
|
61
|
+
} as Data;
|
|
62
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Data, Route, ViewType } from '@/types';
|
|
2
|
+
import { extractMiniCards, processWithWp, rootUrl } from './utils';
|
|
3
|
+
export const route: Route = {
|
|
4
|
+
path: '/popular',
|
|
5
|
+
view: ViewType.Articles,
|
|
6
|
+
categories: ['programming'],
|
|
7
|
+
example: '/css-tricks/popular',
|
|
8
|
+
features: {
|
|
9
|
+
requireConfig: false,
|
|
10
|
+
requirePuppeteer: false,
|
|
11
|
+
antiCrawler: false,
|
|
12
|
+
supportBT: false,
|
|
13
|
+
supportPodcast: false,
|
|
14
|
+
supportScihub: false,
|
|
15
|
+
},
|
|
16
|
+
radar: [
|
|
17
|
+
{
|
|
18
|
+
source: ['css-tricks.com'],
|
|
19
|
+
target: '/popular',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
name: 'Popular this month',
|
|
23
|
+
maintainers: ['Rjnishant530'],
|
|
24
|
+
handler,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
async function handler() {
|
|
28
|
+
const { cards: popularCards } = await extractMiniCards('div.popular-articles > div.mini-card-grid article.mini-card.module.module-article');
|
|
29
|
+
const items = await processWithWp(popularCards, true);
|
|
30
|
+
return {
|
|
31
|
+
title: 'Popular this month',
|
|
32
|
+
description: 'Popular CSS articles this month',
|
|
33
|
+
link: rootUrl,
|
|
34
|
+
item: items,
|
|
35
|
+
language: 'en',
|
|
36
|
+
logo: `${rootUrl}/favicon.ico`,
|
|
37
|
+
icon: `${rootUrl}/favicon.ico`,
|
|
38
|
+
} as Data;
|
|
39
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { load } from 'cheerio';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import { DataItem } from '@/types';
|
|
4
|
+
import { parseDate } from '@/utils/parse-date';
|
|
5
|
+
|
|
6
|
+
export const rootUrl = 'https://css-tricks.com';
|
|
7
|
+
type Card = {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
link: string;
|
|
11
|
+
thumbnail: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export async function extractMiniCards(cardselector: string, titleSelector: string = '', descSelector: string = '') {
|
|
15
|
+
const response = await ofetch(rootUrl);
|
|
16
|
+
const $ = load(response);
|
|
17
|
+
const cards = $(cardselector).toArray();
|
|
18
|
+
const title = titleSelector ? $(titleSelector).text().trim() : '';
|
|
19
|
+
const description = descSelector ? $(descSelector).text().trim() : '';
|
|
20
|
+
return {
|
|
21
|
+
title,
|
|
22
|
+
description,
|
|
23
|
+
cards,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function extractCardsInfo(cards) {
|
|
28
|
+
return cards.map((card) => {
|
|
29
|
+
const $ = load(card);
|
|
30
|
+
const id = $(card).attr('id');
|
|
31
|
+
const thumbnail = $(card).find('div.article-thumbnail-wrap > a >img').attr('src');
|
|
32
|
+
const article = $('div.article-article');
|
|
33
|
+
const title = article.find('h2 > a').text();
|
|
34
|
+
const link = article.find('h2 > a').attr('href');
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
title,
|
|
38
|
+
link,
|
|
39
|
+
thumbnail,
|
|
40
|
+
} as Card;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function extractMiniCardsInfo(cards) {
|
|
45
|
+
return cards.map((card) => {
|
|
46
|
+
const $ = load(card);
|
|
47
|
+
const id = $(card).attr('id')?.replace('mini-', '');
|
|
48
|
+
const thumbnail = '';
|
|
49
|
+
const title = $('h3.mini-card-title').find('a:not(.aal_anchor)').text();
|
|
50
|
+
const link = $('h3.mini-card-title').find('a:not(.aal_anchor)').attr('href');
|
|
51
|
+
return {
|
|
52
|
+
id,
|
|
53
|
+
title,
|
|
54
|
+
link,
|
|
55
|
+
thumbnail,
|
|
56
|
+
} as Card;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function processWithWp(cards, mini: boolean = false, type: string = 'posts') {
|
|
61
|
+
const cardsWithInfo = mini ? extractMiniCardsInfo(cards) : extractCardsInfo(cards);
|
|
62
|
+
const ids = cardsWithInfo.map((card: Card) => card.id.replace('post-', ''));
|
|
63
|
+
const allPosts = await ofetch(`${rootUrl}/wp-json/wp/v2/${type}?include=${ids.join(',')}&_embed&per_page=${ids.length}`);
|
|
64
|
+
// To maintain the ID/post Order
|
|
65
|
+
const idMappedPost = Object.fromEntries(allPosts.map((post) => [post.id, post]));
|
|
66
|
+
return ids.map((id) => extractPostDetails(idMappedPost[id]));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function extractPostDetails(data) {
|
|
70
|
+
const title = data.title.rendered;
|
|
71
|
+
const link = data.link;
|
|
72
|
+
const content = data.content.rendered;
|
|
73
|
+
const summary = data.excerpt.rendered;
|
|
74
|
+
const date = data.date_gmt;
|
|
75
|
+
const updateDate = data.modified_gmt;
|
|
76
|
+
const author = data._embedded?.author;
|
|
77
|
+
const authorName = author?.[0]?.name;
|
|
78
|
+
const authorUrl = author?.[0]?.link;
|
|
79
|
+
const authorAvatar = author?.[0]?.avatar_urls['48'];
|
|
80
|
+
const thumbnail = data._embedded?.['wp:featuredmedia']?.[0]?.source_url;
|
|
81
|
+
const tags = data._embedded?.['wp:term']?.[1]?.map((tag) => tag.name);
|
|
82
|
+
return {
|
|
83
|
+
title,
|
|
84
|
+
link,
|
|
85
|
+
description: content,
|
|
86
|
+
banner: thumbnail,
|
|
87
|
+
image: thumbnail,
|
|
88
|
+
pubDate: parseDate(date),
|
|
89
|
+
updated: parseDate(updateDate),
|
|
90
|
+
author: [
|
|
91
|
+
{
|
|
92
|
+
name: authorName || '',
|
|
93
|
+
url: authorUrl || '',
|
|
94
|
+
avatar: authorAvatar || '',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
content: {
|
|
98
|
+
html: content,
|
|
99
|
+
text: summary,
|
|
100
|
+
},
|
|
101
|
+
category: tags,
|
|
102
|
+
} as DataItem;
|
|
103
|
+
}
|