From c88553b225771c1bbf980fb99385d213d98394fa Mon Sep 17 00:00:00 2001
From: DIYgod
Date: Wed, 28 Feb 2024 16:25:59 +0800
Subject: [PATCH] feat: v3 migration - 1/n
---
lib/v2/0818tuan/index.js | 16 ++++-----
lib/v2/12306/index.js | 18 +++++-----
lib/v2/12306/zxdt.js | 14 ++++----
lib/v2/141jav/index.js | 14 ++++----
lib/v2/141ppv/index.js | 14 ++++----
lib/v2/163/ds.js | 12 +++----
lib/v2/163/dy.js | 10 +++---
lib/v2/163/dy2.js | 16 ++++-----
lib/v2/163/exclusive.js | 18 +++++-----
lib/v2/163/music/artist-songs.js | 8 ++---
lib/v2/163/music/artist.js | 10 +++---
lib/v2/163/music/djradio.js | 12 +++----
lib/v2/163/music/playlist.js | 12 +++----
lib/v2/163/music/userevents.js | 8 ++---
lib/v2/163/music/userplaylist.js | 10 +++---
lib/v2/163/music/userplayrecords.js | 14 ++++----
lib/v2/163/news/rank.js | 20 +++++------
lib/v2/163/news/special.js | 16 ++++-----
lib/v2/163/open/vip.js | 16 ++++-----
lib/v2/163/renjian.js | 22 ++++++------
lib/v2/163/today.js | 18 +++++-----
lib/v2/163/utils.js | 8 ++---
lib/v2/18comic/album.js | 18 +++++-----
lib/v2/18comic/blogs.js | 18 +++++-----
lib/v2/18comic/index.js | 10 +++---
lib/v2/18comic/search.js | 12 +++----
lib/v2/18comic/utils.js | 20 +++++------
lib/v2/19lou/index.js | 18 +++++-----
lib/v2/1lou/index.js | 18 +++++-----
lib/v2/1point3acres/blog.js | 14 ++++----
lib/v2/1point3acres/category.js | 12 +++----
lib/v2/1point3acres/offer.js | 10 +++---
lib/v2/1point3acres/section.js | 12 +++----
lib/v2/1point3acres/thread.js | 10 +++---
lib/v2/1point3acres/user/post.js | 6 ++--
lib/v2/1point3acres/user/thread.js | 6 ++--
lib/v2/1point3acres/utils.js | 6 ++--
lib/v2/2048/index.js | 24 ++++++-------
lib/v2/2cycd/index.js | 20 +++++------
lib/v2/36kr/hot-list.js | 12 +++----
lib/v2/36kr/index.js | 14 ++++----
lib/v2/36kr/utils.js | 6 ++--
lib/v2/3dmgame/game.js | 12 +++----
lib/v2/3dmgame/news-center.js | 14 ++++----
lib/v2/3dmgame/utils.js | 10 +++---
lib/v2/423down/index.js | 14 ++++----
lib/v2/4gamers/category.js | 8 ++---
lib/v2/4gamers/tag.js | 8 ++---
lib/v2/4gamers/topic.js | 8 ++---
lib/v2/4gamers/utils.js | 6 ++--
lib/v2/4ksj/forum.js | 22 ++++++------
lib/v2/500px/tribe-set.js | 10 +++---
lib/v2/500px/user.js | 10 +++---
lib/v2/500px/utils.js | 8 ++---
lib/v2/50forum/zhuanjia.js | 16 ++++-----
lib/v2/52hrtt/index.js | 20 +++++------
lib/v2/52hrtt/symposium.js | 20 +++++------
lib/v2/56kog/class.js | 2 +-
lib/v2/56kog/top.js | 2 +-
lib/v2/56kog/util.js | 14 ++++----
lib/v2/591/list.js | 20 +++++------
lib/v2/5eplay/index.js | 14 ++++----
lib/v2/6park/index.js | 24 ++++++-------
lib/v2/6park/news.js | 24 ++++++-------
lib/v2/6v123/latest-movies.js | 4 +--
lib/v2/6v123/latest-tvseries.js | 4 +--
lib/v2/6v123/utils.js | 12 +++----
lib/v2/78dm/index.js | 20 +++++------
lib/v2/7mmtv/index.js | 22 ++++++------
lib/v2/81/81rc/index.js | 18 +++++-----
lib/v2/8264/list.js | 20 +++++------
lib/v2/8kcos/article.js | 10 +++---
lib/v2/8kcos/cat.js | 14 ++++----
lib/v2/8kcos/latest.js | 14 ++++----
lib/v2/8kcos/tag.js | 14 ++++----
lib/v2/8world/index.js | 14 ++++----
lib/v2/91porn/author.js | 18 +++++-----
lib/v2/91porn/index.js | 18 +++++-----
lib/v2/91porn/utils.js | 6 ++--
lib/v2/95mm/category.js | 2 +-
lib/v2/95mm/tab.js | 2 +-
lib/v2/95mm/tag.js | 2 +-
lib/v2/95mm/utils.js | 8 ++---
lib/v2/9to5/subsite.js | 16 ++++-----
lib/v2/9to5/utils.js | 4 +--
lib/v2/aamacau/index.js | 18 +++++-----
lib/v2/abc/index.js | 18 +++++-----
lib/v2/abmedia/category.js | 12 +++----
lib/v2/abmedia/index.js | 10 +++---
lib/v2/abskoop/index.js | 14 ++++----
lib/v2/abskoop/nsfw.js | 10 +++---
lib/v2/acfun/article.js | 12 +++----
lib/v2/acfun/bangumi.js | 8 ++---
lib/v2/acfun/video.js | 14 ++++----
lib/v2/acg17/post.js | 8 ++---
lib/v2/acpaa/index.js | 18 +++++-----
lib/v2/acs/journal.js | 19 ++++++-----
lib/v2/aeaweb/index.js | 20 +++++------
lib/v2/aeon/category.js | 12 +++----
lib/v2/aeon/type.js | 12 +++----
lib/v2/aeon/utils.js | 10 +++---
lib/v2/agefans/detail.js | 14 ++++----
lib/v2/agefans/update.js | 12 +++----
lib/v2/agirls/index.js | 10 +++---
lib/v2/agirls/topic-list.js | 10 +++---
lib/v2/agirls/topic.js | 10 +++---
lib/v2/agirls/utils.js | 8 ++---
lib/v2/agora0/index.js | 18 +++++-----
lib/v2/agora0/pen0.js | 14 ++++----
lib/v2/ahjzu/news.js | 16 ++++-----
lib/v2/aicaijing/index.js | 16 ++++-----
lib/v2/aiea/index.js | 2 +-
lib/v2/aijishu/index.js | 10 +++---
lib/v2/aijishu/utils.js | 8 ++---
lib/v2/ainvest/article.js | 10 +++---
lib/v2/ainvest/news.js | 10 +++---
lib/v2/aip/journal-pupp.js | 17 +++++-----
lib/v2/aip/journal.js | 14 ++++----
lib/v2/aip/utils.js | 2 +-
lib/v2/airchina/index.js | 6 ++--
lib/v2/aisixiang/column.js | 16 ++++-----
lib/v2/aisixiang/thinktank.js | 12 +++----
lib/v2/aisixiang/toplist.js | 14 ++++----
lib/v2/aisixiang/utils.js | 10 +++---
lib/v2/aisixiang/zhuanti.js | 16 ++++-----
lib/v2/ajmide/index.js | 12 +++----
lib/v2/aliresearch/information.js | 14 ++++----
lib/v2/alistapart/index.js | 4 +--
lib/v2/alistapart/topic.js | 4 +--
lib/v2/alistapart/utils.js | 6 ++--
lib/v2/aliyun/database-month.js | 12 +++----
lib/v2/aliyun/developer/group.js | 14 ++++----
lib/v2/aliyun/notice.js | 18 +++++-----
lib/v2/aljazeera/index.js | 18 +++++-----
lib/v2/ally/rail.js | 18 +++++-----
lib/v2/alternativeto/platform.js | 12 +++----
lib/v2/alternativeto/software.js | 12 +++----
lib/v2/alternativeto/utils.js | 4 ++-
lib/v2/amazon/awsblogs.js | 10 +++---
lib/v2/amazon/kindle-software-updates.js | 12 +++----
lib/v2/android/platform-tools-releases.js | 12 +++----
lib/v2/annualreviews/index.js | 14 ++++----
lib/v2/anquanke/category.js | 18 +++++-----
lib/v2/anquanke/vul.js | 12 +++----
lib/v2/apache/apisix/blog.js | 12 +++----
lib/v2/apiseven/blog.js | 16 ++++-----
lib/v2/apkpure/versions.js | 13 +++----
lib/v2/apnews/topics.js | 16 ++++-----
lib/v2/app-center/release.js | 16 ++++-----
lib/v2/apple/apps.js | 18 +++++-----
lib/v2/apple/exchange-repair.js | 16 ++++-----
lib/v2/appleinsider/index.js | 18 +++++-----
lib/v2/appstore/in-app-purchase.js | 14 ++++----
lib/v2/appstore/price.js | 16 ++++-----
lib/v2/appstore/xianmian.js | 8 ++---
lib/v2/aqara/community.js | 14 ++++----
lib/v2/aqara/news.js | 16 ++++-----
lib/v2/aqara/post.js | 18 +++++-----
lib/v2/arcteryx/new-arrivals.js | 8 ++---
lib/v2/arcteryx/outlet.js | 8 ++---
lib/v2/arcteryx/regear-new-arrivals.js | 12 +++----
lib/v2/arknights/announce.js | 12 +++----
lib/v2/arknights/japan.js | 8 ++---
lib/v2/arknights/news.js | 14 ++++----
lib/v2/artstation/user.js | 12 +++----
lib/v2/asiantolick/index.js | 20 +++++------
lib/v2/asus/bios.js | 12 +++----
lib/v2/asus/gpu-tweak.js | 12 +++----
lib/v2/atcoder/contest.js | 24 ++++++-------
lib/v2/atcoder/post.js | 18 +++++-----
lib/v2/auto-stats/index.js | 18 +++++-----
lib/v2/baai/comments.js | 12 +++----
lib/v2/baai/events.js | 8 ++---
lib/v2/baai/hub.js | 12 +++----
lib/v2/baai/utils.js | 6 ++--
lib/v2/backlinko/blog.js | 12 +++----
lib/v2/bad/index.js | 14 ++++----
lib/v2/baidu/gushitong/index.js | 8 ++---
lib/v2/baidu/search.js | 14 ++++----
lib/v2/baidu/tieba/forum.js | 21 ++++++------
lib/v2/baidu/tieba/post.js | 18 +++++-----
lib/v2/baidu/tieba/search.js | 20 +++++------
lib/v2/baidu/tieba/user.js | 16 ++++-----
lib/v2/baidu/top.js | 12 +++----
lib/v2/bandcamp/live.js | 12 +++----
lib/v2/bandcamp/tag.js | 14 ++++----
lib/v2/bandcamp/weekly.js | 10 +++---
lib/v2/bangumi/moe/index.js | 10 +++---
lib/v2/bangumi/online/online.js | 10 +++---
lib/v2/bangumi/tv/calendar/_base.js | 4 +--
lib/v2/bangumi/tv/calendar/today.js | 6 ++--
lib/v2/bangumi/tv/group/reply.js | 16 ++++-----
lib/v2/bangumi/tv/group/topic.js | 16 ++++-----
lib/v2/bangumi/tv/other/followrank.js | 12 +++----
lib/v2/bangumi/tv/person/index.js | 14 ++++----
lib/v2/bangumi/tv/subject/comments.js | 6 ++--
lib/v2/bangumi/tv/subject/ep.js | 6 ++--
lib/v2/bangumi/tv/subject/index.js | 8 ++---
.../bangumi/tv/subject/offcial-subject-api.js | 4 +--
lib/v2/bangumi/tv/user/blog.js | 18 +++++-----
lib/v2/bangumi/tv/user/wish.js | 18 +++++-----
lib/v2/baozimh/index.js | 16 ++++-----
lib/v2/barronschina/index.js | 18 +++++-----
lib/v2/bast/index.js | 20 +++++------
lib/v2/bbc/index.js | 10 +++---
lib/v2/bbcnewslabs/news.js | 12 +++----
lib/v2/bdys/index.js | 34 +++++++++----------
lib/v2/behance/user.js | 16 ++++-----
lib/v2/bellroy/new-releases.js | 6 ++--
lib/v2/bendibao/news.js | 20 +++++------
lib/v2/bgmlist/onair.js | 10 +++---
lib/v2/bigquant/collections.js | 8 ++---
lib/v2/bilibili/app.js | 8 ++---
lib/v2/bilibili/article.js | 10 +++---
lib/v2/bilibili/audio.js | 8 ++---
lib/v2/bilibili/bangumi.js | 10 +++---
lib/v2/bilibili/cache.js | 8 ++---
lib/v2/bilibili/coin.js | 12 +++----
lib/v2/bilibili/danmaku.js | 14 ++++----
lib/v2/bilibili/dynamic.js | 14 ++++----
lib/v2/bilibili/fav.js | 16 ++++-----
lib/v2/bilibili/followers.js | 12 +++----
lib/v2/bilibili/followings-article.js | 10 +++---
lib/v2/bilibili/followings-dynamic.js | 12 +++----
lib/v2/bilibili/followings-video.js | 12 +++----
lib/v2/bilibili/followings.js | 12 +++----
lib/v2/bilibili/hot-search.js | 6 ++--
lib/v2/bilibili/link-news.js | 8 ++---
lib/v2/bilibili/live-area.js | 10 +++---
lib/v2/bilibili/live-room.js | 8 ++---
lib/v2/bilibili/live-search.js | 10 +++---
lib/v2/bilibili/mall-ip.js | 8 ++---
lib/v2/bilibili/mall-new.js | 8 ++---
lib/v2/bilibili/manga-followings.js | 12 +++----
lib/v2/bilibili/manga-update.js | 8 ++---
lib/v2/bilibili/page.js | 12 +++----
lib/v2/bilibili/partion-ranking.js | 12 +++----
lib/v2/bilibili/partion.js | 10 +++---
lib/v2/bilibili/platform.js | 10 +++---
lib/v2/bilibili/popular.js | 8 ++---
lib/v2/bilibili/ranking.js | 14 ++++----
lib/v2/bilibili/readlist.js | 8 ++---
lib/v2/bilibili/reply.js | 8 ++---
lib/v2/bilibili/user-bangumi.js | 10 +++---
lib/v2/bilibili/user-channel.js | 16 ++++-----
lib/v2/bilibili/user-collection.js | 16 ++++-----
lib/v2/bilibili/user-fav.js | 12 +++----
lib/v2/bilibili/utils.js | 4 +--
lib/v2/bilibili/video-all.js | 12 +++----
lib/v2/bilibili/video.js | 10 +++---
lib/v2/bilibili/vsearch.js | 18 +++++-----
lib/v2/bilibili/watchlater.js | 14 ++++----
lib/v2/bilibili/weekly-recommend.js | 8 ++---
lib/v2/bing/daily-wallpaper.js | 8 ++---
lib/v2/bing/search.js | 8 ++---
lib/v2/biodiscover/index.js | 16 ++++-----
lib/v2/bioone/featured.js | 16 ++++-----
lib/v2/bioone/journal.js | 18 +++++-----
lib/v2/biquge/index.js | 22 ++++++------
lib/v2/bit/cs/cs.js | 10 +++---
lib/v2/bit/cs/utils.js | 16 ++++-----
lib/v2/bit/jwc/jwc.js | 10 +++---
lib/v2/bit/jwc/utils.js | 16 ++++-----
lib/v2/bit/rszhaopin.js | 8 ++---
lib/v2/bit/yjs.js | 12 +++----
lib/v2/bitbucket/commits.js | 14 ++++----
lib/v2/bitbucket/tags.js | 14 ++++----
lib/v2/bitmovin/blog.js | 10 +++---
lib/v2/bjfu/grs.js | 16 ++++-----
lib/v2/bjfu/it/index.js | 14 ++++----
lib/v2/bjfu/it/utils.js | 18 +++++-----
lib/v2/bjfu/jwc/index.js | 12 +++----
lib/v2/bjfu/jwc/utils.js | 16 ++++-----
lib/v2/bjfu/kjc.js | 16 ++++-----
lib/v2/bjfu/news/index.js | 14 ++++----
lib/v2/bjfu/news/utils.js | 16 ++++-----
lib/v2/bjp/apod.js | 16 ++++-----
lib/v2/bjsk/index.js | 14 ++++----
lib/v2/bjsk/keti.js | 18 +++++-----
lib/v2/bjwxdxh/index.js | 18 +++++-----
lib/v2/bjx/huanbao.js | 18 +++++-----
lib/v2/bjx/types.js | 14 ++++----
lib/v2/blizzard/news.js | 18 +++++-----
lib/v2/bloomberg/authors.js | 10 +++---
lib/v2/bloomberg/index.js | 4 +--
lib/v2/bloomberg/utils.js | 22 ++++++------
lib/v2/bluestacks/release.js | 9 ++---
lib/v2/bmkg/earthquake.js | 14 ++++----
lib/v2/bmkg/news.js | 12 +++----
lib/v2/bnu/bs.js | 16 ++++-----
lib/v2/bnu/dwxgb.js | 14 ++++----
lib/v2/bnu/fdy.js | 14 ++++----
lib/v2/bnu/lib.js | 14 ++++----
lib/v2/boc/whpj.js | 12 +++----
lib/v2/bookfere/category.js | 14 ++++----
lib/v2/booru/mmda.js | 12 +++----
lib/v2/bossdesign/index.js | 10 +++---
lib/v2/brave/latest.js | 12 +++----
lib/v2/brooklynmuseum/exhibitions.js | 2 +-
lib/v2/bse/index.js | 16 ++++-----
lib/v2/bsky/keyword.js | 6 ++--
lib/v2/bsky/posts.js | 12 +++----
lib/v2/bsky/utils.js | 4 +--
lib/v2/btzj/index.js | 26 +++++++-------
lib/v2/buaa/news/index.js | 16 ++++-----
lib/v2/buaa/sme.js | 16 ++++-----
lib/v2/bulianglin/bulianglin.js | 12 +++----
lib/v2/bupt/rczp.js | 16 ++++-----
lib/v2/byteclicks/index.js | 8 ++---
lib/v2/byteclicks/tag.js | 8 ++---
lib/v2/byteclicks/utils.js | 2 +-
lib/v2/bytes/bytes.js | 12 +++----
lib/v2/c114/roll.js | 18 +++++-----
lib/v2/caai/index.js | 16 ++++-----
lib/v2/caai/utils.js | 14 ++++----
lib/v2/caam/index.js | 16 ++++-----
lib/v2/caareviews/book.js | 4 +--
lib/v2/caareviews/essay.js | 4 +--
lib/v2/caareviews/exhibition.js | 4 +--
lib/v2/caareviews/utils.js | 12 +++----
lib/v2/cahkms/index.js | 16 ++++-----
lib/v2/caijing/roll.js | 14 ++++----
lib/v2/caixin/article.js | 8 ++---
lib/v2/caixin/blog.js | 10 +++---
lib/v2/caixin/category.js | 20 +++++------
lib/v2/caixin/database.js | 18 +++++-----
lib/v2/caixin/k.js | 8 ++---
lib/v2/caixin/latest.js | 12 +++----
lib/v2/caixin/utils.js | 10 +++---
lib/v2/caixin/weekly.js | 16 ++++-----
lib/v2/caixinglobal/latest.js | 14 ++++----
lib/v2/camchina/index.js | 16 ++++-----
lib/v2/cankaoxiaoxi/index.js | 16 ++++-----
lib/v2/cartoonmad/comic.js | 16 ++++-----
lib/v2/cas/cg/index.js | 22 ++++++------
lib/v2/cas/genetics/index.js | 12 +++----
lib/v2/cas/ia/yjs.js | 10 +++---
lib/v2/cas/iee/kydt.js | 16 ++++-----
lib/v2/cas/is/index.js | 14 ++++----
lib/v2/cas/mesalab/kb.js | 10 +++---
lib/v2/cas/sim/kyjz.js | 14 ++++----
lib/v2/cast/index.js | 20 +++++------
lib/v2/cau/ele.js | 12 +++----
lib/v2/cau/yjs.js | 12 +++----
lib/v2/caus/index.js | 8 ++---
lib/v2/cbaigui/index.js | 18 +++++-----
lib/v2/cbaigui/utils.js | 2 +-
lib/v2/cbc/topics.js | 14 ++++----
lib/v2/cbirc/index.js | 8 ++---
lib/v2/cbnweek/index.js | 8 ++---
lib/v2/ccac/news.js | 23 +++++++------
lib/v2/ccf/ccfcv/index.js | 20 +++++------
lib/v2/ccf/news.js | 16 ++++-----
lib/v2/ccf/tfbd/index.js | 16 ++++-----
lib/v2/ccf/tfbd/utils.js | 14 ++++----
lib/v2/ccnu/career.js | 12 +++----
lib/v2/ccnu/cs.js | 12 +++----
lib/v2/ccnu/wu.js | 12 +++----
lib/v2/ccnu/yjs.js | 12 +++----
lib/v2/ccreports/index.js | 16 ++++-----
lib/v2/cctv/jx.js | 16 ++++-----
lib/v2/cctv/lm.js | 16 ++++-----
lib/v2/cctv/utils/mzzlbg.js | 6 ++--
lib/v2/cctv/utils/news.js | 10 +++---
lib/v2/cctv/utils/xinwen1j1.js | 12 +++----
lib/v2/cctv/xwlb.js | 18 +++++-----
lib/v2/cde/index.js | 18 +++++-----
lib/v2/cde/utils.js | 2 +-
lib/v2/cde/xxgk.js | 10 +++---
lib/v2/cde/zdyz.js | 12 +++----
lib/v2/cdi/index.js | 18 +++++-----
lib/v2/cdzjryb/project-list.js | 16 ++++-----
lib/v2/cebbank/all.js | 24 ++++++-------
lib/v2/cebbank/history.js | 20 +++++------
lib/v2/cfachina/analygarden.js | 16 ++++-----
lib/v2/cfmmc/index.js | 18 +++++-----
lib/v2/cgtn/podcast.js | 10 +++---
lib/v2/chaincatcher/home.js | 14 ++++----
lib/v2/chaincatcher/news.js | 14 ++++----
lib/v2/changba/user.js | 16 ++++-----
lib/v2/chaoxing/qk.js | 20 +++++------
lib/v2/chaping/banner.js | 8 ++---
lib/v2/chaping/news.js | 18 +++++-----
lib/v2/chaping/newsflash.js | 8 ++---
lib/v2/chiculture/topic.js | 16 ++++-----
lib/v2/china/finance/finance.js | 20 +++++------
lib/v2/china/news/highlights/news.js | 14 ++++----
lib/v2/china/news/military/news.js | 12 +++----
lib/v2/chinadegrees/province.js | 17 +++++-----
lib/v2/chinafactcheck/index.js | 10 +++---
lib/v2/chinafactcheck/utils.js | 14 ++++----
lib/v2/chinaisa/index.js | 18 +++++-----
lib/v2/chinamoney/notice.js | 14 ++++----
lib/v2/chinanews/index.js | 18 +++++-----
lib/v2/chinathinktanks/viewpoint.js | 16 ++++-----
lib/v2/chinaventure/index.js | 20 +++++------
lib/v2/chinawriter/index.js | 18 +++++-----
lib/v2/chsi/hotnews.js | 14 ++++----
lib/v2/chsi/kydt.js | 16 ++++-----
lib/v2/chsi/kyzx.js | 16 ++++-----
lib/v2/chuanliu/nice.js | 16 ++++-----
lib/v2/cib/whpj.js | 16 ++++-----
lib/v2/ciidbnu/index.js | 18 +++++-----
lib/v2/civitai/discussions.js | 14 ++++----
lib/v2/civitai/models.js | 8 ++---
lib/v2/clickme/index.js | 18 +++++-----
lib/v2/cloudnative/blog.js | 14 ++++----
lib/v2/cls/depth.js | 18 +++++-----
lib/v2/cls/hot.js | 16 ++++-----
lib/v2/cls/telegraph.js | 14 ++++----
lib/v2/cma/channel.js | 16 ++++-----
lib/v2/cmde/index.js | 19 ++++++-----
lib/v2/cmpxchg8b/articles.js | 12 +++----
lib/v2/cn-healthcare/index.js | 8 ++---
lib/v2/cna/index.js | 18 +++++-----
lib/v2/cna/web/index.js | 20 +++++------
lib/v2/cnbc/rss.js | 10 +++---
lib/v2/cnbeta/type.js | 16 ++++-----
lib/v2/cnbeta/utils.js | 10 +++---
lib/v2/cnblogs/common.js | 14 ++++----
lib/v2/cncf/index.js | 16 ++++-----
lib/v2/cncf/reports.js | 14 ++++----
lib/v2/cneb/router.js | 1 -
lib/v2/cneb/yjxw.js | 20 +++++------
lib/v2/cneb/yjxx.js | 12 +++----
lib/v2/cngal/entry.js | 14 ++++----
lib/v2/cngal/weekly.js | 10 +++---
lib/v2/cnjxol/index.js | 24 ++++++-------
lib/v2/cnki/author.js | 10 +++---
lib/v2/cnki/debut.js | 18 +++++-----
lib/v2/cnki/journals.js | 16 ++++-----
lib/v2/cnki/utils.js | 8 ++---
lib/v2/cnljxh/index.js | 16 ++++-----
lib/v2/cntheory/paper.js | 20 +++++------
lib/v2/cntv/column.js | 14 ++++----
lib/v2/codeforces/contests.js | 8 ++---
lib/v2/codeforces/recent-actions.js | 14 ++++----
lib/v2/coindesk/index.js | 12 +++----
lib/v2/comicat/search.js | 16 ++++-----
lib/v2/comicskingdom/index.js | 18 +++++-----
lib/v2/consumer/index.js | 20 +++++------
lib/v2/consumer/shopping-guide.js | 14 ++++----
lib/v2/cool18/index.js | 22 ++++++------
lib/v2/coolapk/dyh.js | 8 ++---
lib/v2/coolapk/hot.js | 10 +++---
lib/v2/coolapk/huati.js | 8 ++---
lib/v2/coolapk/toutiao.js | 8 ++---
lib/v2/coolapk/tuwen.js | 8 ++---
lib/v2/coolapk/user-dynamic.js | 8 ++---
lib/v2/coolapk/utils.js | 10 +++---
lib/v2/coomer/artist.js | 2 +-
lib/v2/coomer/utils.js | 12 +++----
lib/v2/copymanga/comic.js | 18 +++++-----
lib/v2/cpcey/index.js | 16 ++++-----
lib/v2/cpuid/news.js | 12 +++----
lib/v2/cqgas/tqtz.js | 14 ++++----
lib/v2/cqwu/index.js | 16 ++++-----
lib/v2/crac/index.js | 16 ++++-----
lib/v2/creative-comic/book.js | 10 +++---
lib/v2/creative-comic/utils.js | 2 +-
lib/v2/crossbell/feeds/following.js | 8 ++---
lib/v2/crossbell/notes/character.js | 8 ++---
lib/v2/crossbell/notes/index.js | 6 ++--
lib/v2/crossbell/notes/source.js | 8 ++---
lib/v2/cs/index.js | 18 +++++-----
lib/v2/cs/video.js | 16 ++++-----
lib/v2/csdn/blog.js | 12 +++----
lib/v2/cssn/iolaw.js | 14 ++++----
lib/v2/cste/index.js | 18 +++++-----
lib/v2/csu/career.js | 18 +++++-----
lib/v2/csu/cse.js | 18 +++++-----
lib/v2/csu/mail.js | 14 ++++----
lib/v2/cts/news.js | 18 +++++-----
lib/v2/cuc/yz.js | 12 +++----
lib/v2/curiouscat/user.js | 6 ++--
lib/v2/curius/links.js | 12 +++----
lib/v2/cw/author.js | 9 ++---
lib/v2/cw/master.js | 9 ++---
lib/v2/cw/sub.js | 9 ++---
lib/v2/cw/today.js | 7 ++--
lib/v2/cw/utils.js | 12 +++----
lib/v2/cyzone/author.js | 6 ++--
lib/v2/cyzone/index.js | 6 ++--
lib/v2/cyzone/label.js | 6 ++--
lib/v2/cyzone/util.js | 10 +++---
lib/v2/cztv/daily.js | 16 ++++-----
lib/v2/cztv/zjxwlb.js | 16 ++++-----
lib/v2/dahecube/index.js | 14 ++++----
lib/v2/daily/discussed.js | 4 +--
lib/v2/daily/index.js | 4 +--
lib/v2/daily/upvoted.js | 4 +--
lib/v2/daily/utils.js | 2 +-
lib/v2/damai/activity.js | 20 +++++------
lib/v2/dapenti/subject.js | 2 +-
lib/v2/dapenti/utils.js | 12 +++----
lib/v2/darwinawards/index.js | 12 +++----
lib/v2/dayanzai/index.js | 14 ++++----
lib/v2/dblp/publication.js | 10 +++---
lib/v2/dcard/section.js | 11 +++---
lib/v2/dcfever/news.js | 10 +++---
lib/v2/dcfever/reviews.js | 10 +++---
lib/v2/dcfever/trading-search.js | 12 +++----
lib/v2/dcfever/trading.js | 12 +++----
lib/v2/dcfever/utils.js | 14 ++++----
lib/v2/ddosi/category.js | 14 ++++----
lib/v2/ddosi/index.js | 12 +++----
lib/v2/deadline/posts.js | 16 ++++-----
lib/v2/dedao/index.js | 14 ++++----
lib/v2/dedao/knowledge.js | 16 ++++-----
lib/v2/dedao/list.js | 16 ++++-----
lib/v2/dedao/user.js | 16 ++++-----
lib/v2/deeplearning/thebatch.js | 6 ++--
lib/v2/deepmind/blog.js | 10 +++---
lib/v2/deltaio/blog.js | 10 +++---
lib/v2/devolverdigital/blog.js | 12 +++----
lib/v2/dgjyw/index.js | 16 ++++-----
lib/v2/dhu/jiaowu/news.js | 16 ++++-----
lib/v2/dhu/news/xsxx.js | 12 +++----
lib/v2/dhu/xxgk/news.js | 14 ++++----
lib/v2/dhu/yjs/news.js | 16 ++++-----
lib/v2/dhu/yjs/zs.js | 16 ++++-----
lib/v2/diandong/news.js | 16 ++++-----
lib/v2/diershoubing/news.js | 12 +++----
lib/v2/discord/channel.js | 12 +++----
lib/v2/discord/discord-api.js | 4 +--
lib/v2/discourse/notifications.js | 10 +++---
lib/v2/discourse/posts.js | 2 +-
lib/v2/discourse/utils.js | 6 ++--
lib/v2/discuz/discuz.js | 34 +++++++++----------
lib/v2/disinfo/publications.js | 14 ++++----
lib/v2/diskanalyzer/whats-new.js | 12 +++----
lib/v2/distill/index.js | 14 ++++----
lib/v2/dlnews/category.js | 12 +++----
lib/v2/dlnews/utils.js | 4 +--
lib/v2/dlsite/campaign.js | 14 ++++----
lib/v2/dlsite/ci-en/article.js | 20 +++++------
lib/v2/dlsite/new.js | 14 ++++----
lib/v2/dlsite/utils.js | 14 ++++----
lib/v2/dmzj/news.js | 16 ++++-----
lib/v2/dn/news.js | 20 +++++------
lib/v2/dnaindia/category.js | 16 ++++-----
lib/v2/dockerhub/build.js | 6 ++--
lib/v2/dockerhub/tag.js | 8 ++---
lib/v2/dockerhub/utils.js | 2 +-
lib/v2/docschina/jsweekly.js | 13 +++----
lib/v2/dol/announce.js | 10 +++---
lib/v2/domp4/detail.js | 10 +++---
lib/v2/domp4/latest.js | 10 +++---
lib/v2/domp4/utils.js | 4 +--
lib/v2/dongqiudi/player-news.js | 2 +-
lib/v2/dongqiudi/result.js | 10 +++---
lib/v2/dongqiudi/router.js | 2 +-
lib/v2/dongqiudi/special.js | 10 +++---
lib/v2/dongqiudi/team-news.js | 2 +-
lib/v2/dongqiudi/top-news.js | 10 +++---
lib/v2/dongqiudi/utils.js | 16 ++++-----
lib/v2/dorohedoro/news.js | 16 ++++-----
lib/v2/douban/book/rank.js | 6 ++--
lib/v2/douban/channel/subject.js | 10 +++---
lib/v2/douban/channel/topic.js | 10 +++---
lib/v2/douban/commercialpress/latest.js | 12 +++----
lib/v2/douban/event/hot.js | 6 ++--
lib/v2/douban/other/bookstore.js | 6 ++--
lib/v2/douban/other/celebrity.js | 14 ++++----
lib/v2/douban/other/classification.js | 12 +++----
lib/v2/douban/other/discussion.js | 14 ++++----
lib/v2/douban/other/doulist.js | 12 +++----
lib/v2/douban/other/explore-column.js | 14 ++++----
lib/v2/douban/other/explore.js | 12 +++----
lib/v2/douban/other/group.js | 16 ++++-----
lib/v2/douban/other/jobs.js | 12 +++----
lib/v2/douban/other/later.js | 10 +++---
lib/v2/douban/other/latest-book.js | 10 +++---
lib/v2/douban/other/latest-music.js | 6 ++--
lib/v2/douban/other/list.js | 12 +++----
lib/v2/douban/other/playing.js | 12 +++----
lib/v2/douban/other/recommended.js | 12 +++----
lib/v2/douban/other/replied.js | 16 ++++-----
lib/v2/douban/other/replies.js | 12 +++----
lib/v2/douban/other/topic.js | 10 +++---
lib/v2/douban/other/ustop.js | 6 ++--
lib/v2/douban/other/weekly-best.js | 10 +++---
lib/v2/douban/people/status.js | 12 +++----
lib/v2/douban/people/wish.js | 16 ++++-----
lib/v2/douyin/hashtag.js | 15 ++++----
lib/v2/douyin/live.js | 9 ++---
lib/v2/douyin/user.js | 14 ++++----
lib/v2/douyin/utils.js | 11 +++---
lib/v2/douyu/group.js | 16 ++++-----
lib/v2/douyu/post.js | 12 +++----
lib/v2/douyu/room.js | 8 ++---
lib/v2/dribbble/keyword.js | 2 +-
lib/v2/dribbble/popular.js | 2 +-
lib/v2/dribbble/user.js | 2 +-
lib/v2/dribbble/utils.js | 18 +++++-----
lib/v2/dtcj/datahero.js | 14 ++++----
lib/v2/dtcj/datainsight.js | 16 ++++-----
lib/v2/duozhuayu/search.js | 12 +++----
lib/v2/dushu/fuzhou/index.js | 8 ++---
lib/v2/dut/index.js | 16 ++++-----
lib/v2/dx2025/index.js | 16 ++++-----
lib/v2/dxy/profile/thread.js | 10 +++---
lib/v2/dxy/special.js | 10 +++---
lib/v2/dxy/utils.js | 8 ++---
lib/v2/e-hentai/index.js | 30 ++++++++--------
lib/v2/eagle/blog.js | 18 +++++-----
lib/v2/eagle/changelog.js | 14 ++++----
lib/v2/earthquake/ceic.js | 12 +++----
lib/v2/earthquake/index.js | 12 +++----
lib/v2/eastday/24.js | 18 +++++-----
lib/v2/eastday/portrait.js | 14 ++++----
lib/v2/eastday/sh.js | 14 ++++----
lib/v2/eastmoney/report/index.js | 14 ++++----
lib/v2/eastmoney/search/index.js | 12 +++----
lib/v2/eastmoney/ttjj/user.js | 12 +++----
lib/v2/ecnu/contest.js | 14 ++++----
lib/v2/ecnu/yjs.js | 14 ++++----
lib/v2/economist/espresso.js | 12 +++----
lib/v2/economist/full.js | 14 ++++----
lib/v2/economist/global-business-review.js | 14 +++++---
lib/v2/ecust/e/news.js | 10 +++---
lib/v2/ecust/gschool/yjs.js | 12 +++----
lib/v2/ecust/jwc/notice.js | 14 ++++----
lib/v2/egsea/flash.js | 8 ++---
lib/v2/ehentai/ehapi.js | 28 +++++++--------
lib/v2/ehentai/favorites.js | 8 ++---
lib/v2/ehentai/search.js | 6 ++--
lib/v2/ehentai/tag.js | 6 ++--
lib/v2/ekantipur/issue.js | 12 +++----
lib/v2/elasticsearch-cn/index.js | 16 ++++-----
lib/v2/eleduck/jobs.js | 8 ++---
lib/v2/eleduck/posts.js | 8 ++---
lib/v2/elsevier/issue.js | 20 +++++------
lib/v2/elsevier/journal.js | 18 +++++-----
lib/v2/embassy/index.js | 18 +++++-----
lib/v2/epicgames/index.js | 14 ++++----
lib/v2/eprice/rss.js | 20 +++++------
lib/v2/eventernote/actors.js | 10 +++---
lib/v2/famitsu/category.js | 16 ++++-----
lib/v2/fansly/post.js | 6 ++--
lib/v2/fansly/tag.js | 6 ++--
lib/v2/fansly/utils.js | 4 +--
lib/v2/fantia/search.js | 24 ++++++-------
lib/v2/fantia/user.js | 20 +++++------
lib/v2/farmatters/index.js | 18 +++++-----
lib/v2/fastbull/express-news.js | 12 +++----
lib/v2/fastbull/news.js | 16 ++++-----
lib/v2/fda/cdrh.js | 18 +++++-----
lib/v2/feng/forum.js | 10 +++---
lib/v2/feng/utils.js | 4 +--
lib/v2/ff14/ff14-global.js | 14 ++++----
lib/v2/ff14/ff14-zh.js | 14 ++++----
lib/v2/fffdm/manhua/manhua.js | 16 ++++-----
lib/v2/finology/bullets.js | 12 +++----
lib/v2/finology/most-viewed.js | 4 +--
lib/v2/finology/tag.js | 4 +--
lib/v2/finology/utils.js | 10 +++---
lib/v2/finviz/news.js | 16 ++++-----
lib/v2/finviz/quote.js | 16 ++++-----
lib/v2/firecore/index.js | 16 ++++-----
lib/v2/firefox/addons.js | 12 +++----
lib/v2/firefox/breaches.js | 14 ++++----
lib/v2/firefox/release.js | 12 +++----
lib/v2/fisher-spb/news.js | 16 ++++-----
lib/v2/fishshell/index.js | 14 ++++----
lib/v2/fjksbm/index.js | 18 +++++-----
lib/v2/flyert/creditcard.js | 12 +++----
lib/v2/flyert/preferential.js | 16 ++++-----
lib/v2/flyert/utils.js | 12 +++----
lib/v2/focustaiwan/index.js | 18 +++++-----
lib/v2/followin/index.js | 6 ++--
lib/v2/followin/kol.js | 6 ++--
lib/v2/followin/news.js | 6 ++--
lib/v2/followin/tag.js | 6 ++--
lib/v2/followin/topic.js | 6 ++--
lib/v2/followin/utils.js | 12 +++----
lib/v2/foresightnews/article.js | 6 ++--
lib/v2/foresightnews/column.js | 6 ++--
lib/v2/foresightnews/index.js | 6 ++--
lib/v2/foresightnews/news.js | 6 ++--
lib/v2/foresightnews/util.js | 6 ++--
lib/v2/foreverblog/feeds.js | 14 ++++----
lib/v2/fortnite/news.js | 14 +++++---
lib/v2/fortunechina/index.js | 16 ++++-----
lib/v2/fosshub/index.js | 16 ++++-----
lib/v2/free/rss.js | 8 ++---
lib/v2/freebuf/index.js | 8 ++---
lib/v2/freecomputerbooks/index.js | 18 +++++-----
lib/v2/freewechat/profile.js | 16 ++++-----
lib/v2/ft/channel.js | 4 +--
lib/v2/ft/myft.js | 12 +++----
lib/v2/ft/utils.js | 6 ++--
lib/v2/fuliba/latest.js | 10 +++---
lib/v2/furstar/archive.js | 12 +++----
lib/v2/furstar/artists.js | 16 ++++-----
lib/v2/furstar/index.js | 16 ++++-----
lib/v2/furstar/utils.js | 16 ++++-----
lib/v2/futunn/main.js | 16 ++++-----
lib/v2/fx-markets/channel.js | 16 ++++-----
lib/v2/fx678/kx.js | 16 ++++-----
lib/v2/fxiaoke/crm.js | 16 ++++-----
lib/v2/fzmtr/announcements.js | 12 +++----
lib/v2/gameapps/index.js | 16 ++++-----
lib/v2/gamebase/news.js | 20 +++++------
lib/v2/gamegene/news.js | 14 ++++----
lib/v2/gamer/gnn-index.js | 20 +++++------
lib/v2/gamer/hot.js | 22 ++++++------
lib/v2/gamersecret/index.js | 22 ++++++------
lib/v2/gamme/category.js | 10 +++---
lib/v2/gamme/tag.js | 14 ++++----
lib/v2/gcores/category.js | 14 ++++----
lib/v2/gcores/collection.js | 6 ++--
lib/v2/gcores/radio.js | 20 +++++------
lib/v2/gcores/tag.js | 16 ++++-----
lib/v2/gdsrx/index.js | 16 ++++-----
lib/v2/gdut/news.js | 14 ++++----
lib/v2/gdut/oa-news.js | 18 +++++-----
lib/v2/gelonghui/home.js | 8 ++---
lib/v2/gelonghui/hot-article.js | 12 +++----
lib/v2/gelonghui/keyword.js | 10 +++---
lib/v2/gelonghui/live.js | 10 +++---
lib/v2/gelonghui/subject.js | 12 +++----
lib/v2/gelonghui/user.js | 10 +++---
lib/v2/gelonghui/utils.js | 8 ++---
lib/v2/geocaching/blogs.js | 10 +++---
lib/v2/getdr/index.js | 12 +++----
lib/v2/getitfree/index.js | 14 ++++----
lib/v2/getitfree/util.js | 6 ++--
lib/v2/gettr/user.js | 10 +++---
lib/v2/gf-cn/news.js | 14 ++++----
lib/v2/gihyo/group.js | 16 ++++-----
lib/v2/gitee/repos/commits.js | 12 +++----
lib/v2/gitee/repos/events.js | 12 +++----
lib/v2/gitee/repos/releases.js | 12 +++----
lib/v2/gitee/users/events.js | 12 +++----
lib/v2/github/branches.js | 12 +++----
lib/v2/github/comments.js | 30 ++++++++--------
lib/v2/github/contributors.js | 8 ++---
lib/v2/github/file.js | 16 ++++-----
lib/v2/github/follower.js | 10 +++---
lib/v2/github/gist.js | 10 +++---
lib/v2/github/issue.js | 20 +++++------
lib/v2/github/notifications.js | 14 ++++----
lib/v2/github/pulls.js | 20 +++++------
lib/v2/github/pulse.js | 16 ++++-----
lib/v2/github/repos.js | 10 +++---
lib/v2/github/search.js | 16 ++++-----
lib/v2/github/star.js | 12 +++----
lib/v2/github/starred-repos.js | 10 +++---
lib/v2/github/topic.js | 16 ++++-----
lib/v2/github/trending.js | 20 +++++------
lib/v2/github/wiki.js | 12 +++----
lib/v2/gitpod/blog.js | 22 ++++++------
lib/v2/gitpod/changelog.js | 12 +++----
lib/v2/globallawreview/index.js | 14 ++++----
lib/v2/gocn/jobs.js | 8 ++---
lib/v2/gocn/news.js | 8 ++---
lib/v2/gocn/topics.js | 8 ++---
lib/v2/gofans/index.js | 10 +++---
lib/v2/gogoanimehd/recent-releases.js | 10 +++---
lib/v2/google/album.js | 8 ++---
lib/v2/google/alerts.js | 10 +++---
lib/v2/google/citations.js | 14 ++++----
lib/v2/google/doodles.js | 6 ++--
lib/v2/google/fonts.js | 16 ++++-----
lib/v2/google/news.js | 20 +++++------
lib/v2/google/scholar.js | 14 ++++----
lib/v2/google/search.js | 14 ++++----
lib/v2/gov/anhui/kjt.js | 16 ++++-----
lib/v2/gov/beijing/bjedu/gh.js | 16 ++++-----
lib/v2/gov/beijing/bphc/index.js | 10 +++---
lib/v2/gov/beijing/jw/tzgg.js | 16 ++++-----
lib/v2/gov/beijing/kw/index.js | 20 +++++------
lib/v2/gov/caac/cjwt.js | 14 ++++----
lib/v2/gov/cac/index.js | 18 +++++-----
lib/v2/gov/ccdi/index.js | 4 +--
lib/v2/gov/ccdi/utils.js | 14 ++++----
lib/v2/gov/chinamine-safety/util.js | 10 +++---
lib/v2/gov/chinamine-safety/xw.js | 16 ++++-----
lib/v2/gov/chinamine-safety/zfxxgk.js | 14 ++++----
lib/v2/gov/chinatax/latest.js | 12 +++----
lib/v2/gov/chongqing/gzw.js | 18 +++++-----
lib/v2/gov/chongqing/rsks.js | 14 ++++----
lib/v2/gov/chongqing/sydwgkzp.js | 14 ++++----
lib/v2/gov/cmse/fxrw.js | 16 ++++-----
lib/v2/gov/cmse/index.js | 20 +++++------
lib/v2/gov/cnnic/index.js | 18 +++++-----
lib/v2/gov/csrc/auditstatus.js | 16 ++++-----
788 files changed, 5034 insertions(+), 5010 deletions(-)
diff --git a/lib/v2/0818tuan/index.js b/lib/v2/0818tuan/index.js
index a07338f8e..6cdfdf582 100644
--- a/lib/v2/0818tuan/index.js
+++ b/lib/v2/0818tuan/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const baseUrl = 'http://www.0818tuan.com';
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const url = `${baseUrl}/list-${listId}-0.html`;
const { data: response } = await got(url);
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = $(listId === '3' ? '.col-xs-12 .thumbnail > a' : '.col-md-8 .list-group > a')
.toArray()
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
$('.pageLink, .alert, p[style="margin:15px;"]').remove();
@@ -38,10 +38,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: url,
image: 'http://www.0818tuan.com/favicon.ico',
item: items,
- };
+ });
};
diff --git a/lib/v2/12306/index.js b/lib/v2/12306/index.js
index 7b5cffd64..b2d0b2518 100644
--- a/lib/v2/12306/index.js
+++ b/lib/v2/12306/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
-const config = require('@/config').value;
+import { config } from '@/config';
const rootUrl = 'https://kyfw.12306.cn';
@@ -46,10 +46,10 @@ function getStationInfo(stationName, ctx) {
}
module.exports = async (ctx) => {
- const date = ctx.params.date;
- const fromStationInfo = await getStationInfo(ctx.params.from, ctx);
- const toStationInfo = await getStationInfo(ctx.params.to, ctx);
- const type = ctx.params.type ?? 'ADULT';
+ const date = ctx.req.param('date');
+ const fromStationInfo = await getStationInfo(ctx.req.param('from'), ctx);
+ const toStationInfo = await getStationInfo(ctx.req.param('to'), ctx);
+ const type = ctx.req.param('type') ?? 'ADULT';
const apiUrl = `${rootUrl}/otn/leftTicket/queryA?leftTicketDTO.train_date=${date}&leftTicketDTO.from_station=${fromStationInfo.code}&leftTicketDTO.to_station=${toStationInfo.code}&purpose_codes=${type}`;
const linkUrl = `${rootUrl}/otn/leftTicket/init?linktypeid=dc&fs=${fromStationInfo.code}&ts=${toStationInfo.code}&date=${date}&flag=N,N,Y`;
@@ -100,9 +100,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${fromStationInfo.name} → ${toStationInfo.name} ${date}`,
link: linkUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/12306/zxdt.js b/lib/v2/12306/zxdt.js
index 787bf573e..0126a7438 100644
--- a/lib/v2/12306/zxdt.js
+++ b/lib/v2/12306/zxdt.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const url = require('url');
module.exports = async (ctx) => {
- const id = ctx.params.id || -1;
+ const id = ctx.req.param('id') || -1;
const link = id === -1 ? 'https://www.12306.cn/mormhweb/zxdt/index_zxdt.html' : `https://www.12306.cn/mormhweb/1/${id}/index_fl.html`;
const response = await got.get(link);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const name = $('div.nav_center > a:nth-child(4)').text();
const list = $('#newList > ul > li')
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
}
const response = await got.get(itemUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let description = $('.article-box').html();
description = description ? description.replaceAll('src="', `src="${url.resolve(itemUrl, '.')}`).trim() : $('.content_text').html() || '文章已被删除';
@@ -50,9 +50,9 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${name}最新动态`,
link,
item: out,
- };
+ });
};
diff --git a/lib/v2/141jav/index.js b/lib/v2/141jav/index.js
index 2b462f677..770305d6f 100644
--- a/lib/v2/141jav/index.js
+++ b/lib/v2/141jav/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
if (ctx.path === '/') {
ctx.redirect(`/141jav${$('.overview').first().attr('href')}`);
@@ -63,9 +63,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `141JAV - ${$('title').text().split('-')[0].trim()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/141ppv/index.js b/lib/v2/141ppv/index.js
index 950254464..8d5c8583e 100644
--- a/lib/v2/141ppv/index.js
+++ b/lib/v2/141ppv/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
if (ctx.path === '/') {
ctx.redirect(`/141ppv${$('.overview').first().attr('href')}`);
@@ -66,9 +66,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `141PPV - ${$('title').text().split('-')[0].trim()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/163/ds.js b/lib/v2/163/ds.js
index 62597b0c3..0c3934cb2 100644
--- a/lib/v2/163/ds.js
+++ b/lib/v2/163/ds.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const root_url = 'https://inf.ds.163.com';
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const current_url = `${root_url}/v1/web/feed/basic/getSomeOneFeeds?feedTypes=1,2,3,4,6,7,10,11&someOneUid=${id}`;
const response = await got({
@@ -25,9 +25,9 @@ module.exports = async (ctx) => {
pubDate: parseDate(feed.updateTime),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${response.data.result.userInfos[0].user.nick} 的动态`,
link: `https://ds.163.com/user/${id}`,
item: list,
- };
+ });
};
diff --git a/lib/v2/163/dy.js b/lib/v2/163/dy.js
index a99467a7e..e4d689b9d 100644
--- a/lib/v2/163/dy.js
+++ b/lib/v2/163/dy.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const { parseDyArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -19,11 +19,11 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((e) => parseDyArticle(charset, e, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title: `网易号 - ${list[0].author}`,
link: items[0].feedLink,
description: items[0].feedDescription,
image: items[0].feedImage,
item: items,
- };
+ });
};
diff --git a/lib/v2/163/dy2.js b/lib/v2/163/dy2.js
index 61724026e..e51bafddf 100644
--- a/lib/v2/163/dy2.js
+++ b/lib/v2/163/dy2.js
@@ -1,20 +1,20 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const { parseDyArticle } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const limit = ctx.query.limit ?? 30;
+ const limit = ctx.req.query('limit') ?? 30;
const url = `https://www.163.com/dy/media/${id}.html`;
const response = await got(url, { responseType: 'buffer' });
const charset = response.headers['content-type'].split('=')[1];
const data = iconv.decode(response.data, charset);
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('.tab_content ul li')
.slice(0, limit)
@@ -31,12 +31,12 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => parseDyArticle(charset, item, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('head title').text()} - 网易号`,
link: url,
description: $('.icon_line.desc').text(),
image: $('.head_img').attr('src'),
item: items,
author: $('h2').text(),
- };
+ });
};
diff --git a/lib/v2/163/exclusive.js b/lib/v2/163/exclusive.js
index 5c27707fa..743274f22 100644
--- a/lib/v2/163/exclusive.js
+++ b/lib/v2/163/exclusive.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const ids = {
@@ -73,7 +73,7 @@ const ids = {
};
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
+ const id = ctx.req.param('id') ?? '';
const rootUrl = 'https://3g.163.com';
const currentUrl = `${rootUrl}/touch/exclusive${id ? `/sub/${id}` : ''}`;
@@ -115,7 +115,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.m-linkCard').remove();
@@ -140,9 +140,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `网易独家 - ${ids[id].title}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/163/music/artist-songs.js b/lib/v2/163/music/artist-songs.js
index c9ff9dc27..1c219e98a 100644
--- a/lib/v2/163/music/artist-songs.js
+++ b/lib/v2/163/music/artist-songs.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -30,10 +30,10 @@ module.exports = async (ctx) => {
link: `https://music.163.com/#/song?id=${song.id}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${artist.name} - 歌手歌曲`,
link: `https://music.163.com/#/artist?id=${id}`,
description: `网易云音乐 - 歌手歌曲 - ${artist.name}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/163/music/artist.js b/lib/v2/163/music/artist.js
index 1430d298b..e41ab19b9 100644
--- a/lib/v2/163/music/artist.js
+++ b/lib/v2/163/music/artist.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const response = await got(`https://music.163.com/api/artist/albums/${id}`, {
headers: {
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
const data = response.data;
- ctx.state.data = {
+ ctx.set('data', {
title: data.artist.name,
link: `https://music.163.com/#/artist/album?id=${id}`,
description: `网易云音乐歌手专辑 - ${data.artist.name}`,
@@ -35,5 +35,5 @@ module.exports = async (ctx) => {
author: singer,
};
}),
- };
+ });
};
diff --git a/lib/v2/163/music/djradio.js b/lib/v2/163/music/djradio.js
index a49ef890f..4698cd947 100644
--- a/lib/v2/163/music/djradio.js
+++ b/lib/v2/163/music/djradio.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const ProcessFeed = (limit, offset) =>
got.post('https://music.163.com/api/dj/program/byradio', {
@@ -62,7 +62,7 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: radio.name,
link: `https://music.163.com/djradio?id=${id}`,
subtitle: radio.desc,
@@ -74,5 +74,5 @@ module.exports = async (ctx) => {
itunes_author: dj.nickname,
itunes_category: radio.category,
item: items.flat(),
- };
+ });
};
diff --git a/lib/v2/163/music/playlist.js b/lib/v2/163/music/playlist.js
index 0a540137f..12c396105 100644
--- a/lib/v2/163/music/playlist.js
+++ b/lib/v2/163/music/playlist.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const config = require('@/config').value;
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { config } from '@/config';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
throw new Error('163 Music RSS is disabled due to the lack of relevant config');
}
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const response = await got.post('https://music.163.com/api/v3/playlist/detail', {
headers: {
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
});
const songs = songinfo.data.songs;
- ctx.state.data = {
+ ctx.set('data', {
title: data.name,
link: `https://music.163.com/#/playlist?id=${id}`,
description: `网易云音乐歌单 - ${data.name}`,
@@ -51,5 +51,5 @@ module.exports = async (ctx) => {
author: singer,
};
}),
- };
+ });
};
diff --git a/lib/v2/163/music/userevents.js b/lib/v2/163/music/userevents.js
index 6344fc473..2976cdea9 100644
--- a/lib/v2/163/music/userevents.js
+++ b/lib/v2/163/music/userevents.js
@@ -1,6 +1,6 @@
const path = require('path');
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const renderDescription = (info) => art(path.join(__dirname, '../templates/music/userevents.art'), info);
module.exports = async (ctx) => {
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const { data } = response;
const { nickname, signature, avatarUrl } = data.events[0].user;
- ctx.state.data = {
+ ctx.set('data', {
title: `${nickname}的云村动态`,
link: `https://music.163.com/#/user/event?id=${id}`,
description: `网易云音乐用户动态 - ${signature}`,
@@ -48,5 +48,5 @@ module.exports = async (ctx) => {
comments: item.info.commentCount,
};
}),
- };
+ });
};
diff --git a/lib/v2/163/music/userplaylist.js b/lib/v2/163/music/userplaylist.js
index bebbe6aec..862ccd7b5 100644
--- a/lib/v2/163/music/userplaylist.js
+++ b/lib/v2/163/music/userplaylist.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
+ const uid = ctx.req.param('uid');
const response = await got.post('https://music.163.com/api/user/playlist', {
headers: {
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
const { nickname, signature, avatarUrl } = creator;
- ctx.state.data = {
+ ctx.set('data', {
title: `${nickname} 的所有歌单`,
link: `https://music.163.com/user/home?id=${uid}`,
subtitle: signature,
@@ -52,5 +52,5 @@ module.exports = async (ctx) => {
category: pl.tags,
};
}),
- };
+ });
};
diff --git a/lib/v2/163/music/userplayrecords.js b/lib/v2/163/music/userplayrecords.js
index 6e6df26bd..e9ae552c5 100644
--- a/lib/v2/163/music/userplayrecords.js
+++ b/lib/v2/163/music/userplayrecords.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const config = require('@/config').value;
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { config } from '@/config';
+import { art } from '@/utils/render';
const path = require('path');
const headers = {
@@ -38,18 +38,18 @@ function getItem(records) {
}
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
- const type = Number.parseInt(ctx.params.type) || 0;
+ const uid = ctx.req.param('uid');
+ const type = Number.parseInt(ctx.req.param('type')) || 0;
const url = `https://music.163.com/api/v1/play/record?uid=${uid}&type=${type}`;
const response = await got(url, { headers });
const records = type === 1 ? response.data.weekData : response.data.allData;
- ctx.state.data = {
+ ctx.set('data', {
title: `${type === 1 ? '听歌榜单(最近一周)' : '听歌榜单(所有时间}'} - ${uid}}`,
link: `https://music.163.com/user/home?id=${uid}`,
updated: response.headers.date,
item: getItem(records),
- };
+ });
};
diff --git a/lib/v2/163/news/rank.js b/lib/v2/163/news/rank.js
index 0bd29561c..25508b185 100644
--- a/lib/v2/163/news/rank.js
+++ b/lib/v2/163/news/rank.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
const rootUrl = 'https://news.163.com';
@@ -76,9 +76,9 @@ const timeRange = {
};
module.exports = async (ctx) => {
- const category = ctx.params.category || 'whole';
- const type = ctx.params.type || 'click';
- const time = ctx.params.time || 'day';
+ const category = ctx.req.param('category') || 'whole';
+ const type = ctx.req.param('type') || 'click';
+ const time = ctx.req.param('time') || 'day';
const cfg = config[category];
if (!cfg) {
@@ -94,7 +94,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
+ const $ = load(iconv.decode(response.data, 'gbk'));
const list = $('div.tabContents')
.eq(timeRange[time].index + (category === 'whole' ? (type === 'click' ? -1 : 2) : type === 'click' ? 0 : 2))
@@ -125,7 +125,7 @@ module.exports = async (ctx) => {
method: 'get',
url: link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.bot_word, .js-open-app, .s-img').remove();
content('video').each(function () {
@@ -147,9 +147,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `网易新闻${timeRange[time].title}${type === 'click' ? '点击' : '跟帖'}榜 - ${cfg.title}`,
link: currentUrl,
item: items.filter(Boolean),
- };
+ });
};
diff --git a/lib/v2/163/news/special.js b/lib/v2/163/news/special.js
index 981545ed5..1a431630e 100644
--- a/lib/v2/163/news/special.js
+++ b/lib/v2/163/news/special.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { load } from 'cheerio';
const typeMap = {
1: '轻松一刻',
2: '槽值',
@@ -19,10 +19,10 @@ const typeMap = {
15: '沸点',
};
module.exports = async (ctx) => {
- if (!ctx.params.type) {
+ if (!ctx.req.param('type')) {
throw new Error('Bad parameter. See https://docs.rsshub.app/routes/game#wang-yi-da-shen');
}
- const selectedType = Number.parseInt(ctx.params.type);
+ const selectedType = Number.parseInt(ctx.req.param('type'));
let type;
switch (selectedType) {
case 1:
@@ -93,7 +93,7 @@ module.exports = async (ctx) => {
}
return ctx.cache.tryGet(url, async () => {
const article_response = await got(url);
- const $ = cheerio.load(article_response.data);
+ const $ = load(article_response.data);
article.link = url;
article.description = $('.article-body').html() || $('div[class="video"]').html();
@@ -106,9 +106,9 @@ module.exports = async (ctx) => {
const selectedTypeName = typeMap[selectedType];
- ctx.state.data = {
+ ctx.set('data', {
title: selectedTypeName ? `${selectedTypeName} - 网易专栏` : '网易专栏',
link: 'https://3g.163.com/touch/exclusive/?referFrom=163',
item: items,
- };
+ });
};
diff --git a/lib/v2/163/open/vip.js b/lib/v2/163/open/vip.js
index 122db3560..5bc23fc16 100644
--- a/lib/v2/163/open/vip.js
+++ b/lib/v2/163/open/vip.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
const url = 'https://vip.open.163.com';
const list_response = await got(url);
- const $ = cheerio.load(list_response.data);
+ const $ = load(list_response.data);
const initialState = JSON.parse(
$('script')
.text()
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(data.courseInfo.description, null, false);
+ const $ = load(data.courseInfo.description, null, false);
$('img').each((_, img) => {
img.attribs.src = img.attribs.src.split('?')[0];
delete img.attribs.width;
@@ -55,9 +55,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '网易公开课 - 精品课程',
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/163/renjian.js b/lib/v2/163/renjian.js
index f6becb638..439ce6416 100644
--- a/lib/v2/163/renjian.js
+++ b/lib/v2/163/renjian.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const titles = {
texie: '特写',
@@ -13,7 +13,7 @@ const titles = {
};
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'texie';
+ const category = ctx.req.param('category') ?? 'texie';
const rootUrl = 'https://renjian.163.com';
const currentUrl = `${rootUrl}/special/renjian_${category}/`;
@@ -31,14 +31,14 @@ module.exports = async (ctx) => {
const urls = data.match(/url:"(.*)",/g);
if (urls) {
- items = urls.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50).map((item) => ({
+ items = urls.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50).map((item) => ({
link: item.match(/url:"(.*)",/)[1],
}));
} else {
- const $ = cheerio.load(data);
+ const $ = load(data);
items = $('.article h3 a')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50)
.toArray()
.map((_, item) => {
item = $(item);
@@ -55,7 +55,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.title = content('h1').text();
item.author = content('script')
@@ -69,9 +69,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `人间 - ${titles[category]} - 网易新闻`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/163/today.js b/lib/v2/163/today.js
index 7514cd247..fa3bbf540 100644
--- a/lib/v2/163/today.js
+++ b/lib/v2/163/today.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const needContent = /t|y/i.test(ctx.params.need_content ?? 'true');
+ const needContent = /t|y/i.test(ctx.req.param('need_content') ?? 'true');
const rootUrl = 'https://gw.m.163.com';
- const currentUrl = `${rootUrl}/nc/api/v1/feed/static/normal-list?start=0&tid=T1573700340788&size=${ctx.query.limit ?? (needContent ? 30 : 200)}`;
+ const currentUrl = `${rootUrl}/nc/api/v1/feed/static/normal-list?start=0&tid=T1573700340788&size=${ctx.req.query('limit') ?? (needContent ? 30 : 200)}`;
const response = await got({
method: 'get',
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.bot_word').remove();
@@ -47,9 +47,9 @@ module.exports = async (ctx) => {
);
}
- ctx.state.data = {
+ ctx.set('data', {
title: '今日关注 - 网易新闻',
link: 'https://wp.m.163.com/163/html/newsapp/todayFocus/index.html',
item: items,
- };
+ });
};
diff --git a/lib/v2/163/utils.js b/lib/v2/163/utils.js
index d952bc736..7f33ebef7 100644
--- a/lib/v2/163/utils.js
+++ b/lib/v2/163/utils.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const { art } = require('@/utils/render');
+import { art } from '@/utils/render';
const path = require('path');
const parseDyArticle = (charset, item, tryGet) =>
@@ -11,7 +11,7 @@ const parseDyArticle = (charset, item, tryGet) =>
});
const html = iconv.decode(response.data, charset);
- const $ = cheerio.load(html);
+ const $ = load(html);
$('.post_main img').each((_, i) => {
if (!i.attribs.src) {
diff --git a/lib/v2/18comic/album.js b/lib/v2/18comic/album.js
index 070597f7a..5e8060a22 100644
--- a/lib/v2/18comic/album.js
+++ b/lib/v2/18comic/album.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const { defaultDomain, getRootUrl } = require('./utils');
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const { domain = defaultDomain } = ctx.query;
- const rootUrl = getRootUrl(domain, ctx);
+ const rootUrl = getRootUrl(domain);
const currentUrl = `${rootUrl}/album/${id}`;
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const category = $('span[data-type="tags"]')
.first()
@@ -53,7 +53,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.tab-content').remove();
@@ -69,10 +69,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
description: $('meta[property="og:description"]').attr('content'),
- };
+ });
};
diff --git a/lib/v2/18comic/blogs.js b/lib/v2/18comic/blogs.js
index a62f0e671..5d72ec303 100644
--- a/lib/v2/18comic/blogs.js
+++ b/lib/v2/18comic/blogs.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const { defaultDomain, getRootUrl } = require('./utils');
module.exports = async (ctx) => {
- const category = ctx.params.category ?? '';
+ const category = ctx.req.param('category') ?? '';
const { domain = defaultDomain } = ctx.query;
- const rootUrl = getRootUrl(domain, ctx);
+ const rootUrl = getRootUrl(domain);
const currentUrl = `${rootUrl}/blogs${category ? `/${category}` : ''}`;
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.title')
.toArray()
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.pubDate = parseDate(content('.date').first().text());
@@ -55,12 +55,12 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title')
.text()
.replace(/最新的/, $('.article-nav .active').text()),
link: currentUrl,
item: items,
description: $('meta[property="og:description"]').attr('content'),
- };
+ });
};
diff --git a/lib/v2/18comic/index.js b/lib/v2/18comic/index.js
index f83569d0c..878b5166f 100644
--- a/lib/v2/18comic/index.js
+++ b/lib/v2/18comic/index.js
@@ -1,12 +1,12 @@
const { defaultDomain, getRootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'all';
- const keyword = ctx.params.keyword ?? '';
- const time = ctx.params.time ?? 'a';
- const order = ctx.params.order ?? 'mr';
+ const category = ctx.req.param('category') ?? 'all';
+ const keyword = ctx.req.param('keyword') ?? '';
+ const time = ctx.req.param('time') ?? 'a';
+ const order = ctx.req.param('order') ?? 'mr';
const { domain = defaultDomain } = ctx.query;
- const rootUrl = getRootUrl(domain, ctx);
+ const rootUrl = getRootUrl(domain);
const currentUrl = `${rootUrl}/albums${category === 'all' ? '' : `/${category}`}${keyword ? `?screen=${keyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`;
diff --git a/lib/v2/18comic/search.js b/lib/v2/18comic/search.js
index 806e6310c..594704563 100644
--- a/lib/v2/18comic/search.js
+++ b/lib/v2/18comic/search.js
@@ -1,13 +1,13 @@
const { defaultDomain, getRootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
- const option = ctx.params.option ?? 'photos';
- const category = ctx.params.category ?? 'all';
- const keyword = ctx.params.keyword ?? '';
- const time = ctx.params.time ?? 'a';
- const order = ctx.params.order ?? 'mr';
+ const option = ctx.req.param('option') ?? 'photos';
+ const category = ctx.req.param('category') ?? 'all';
+ const keyword = ctx.req.param('keyword') ?? '';
+ const time = ctx.req.param('time') ?? 'a';
+ const order = ctx.req.param('order') ?? 'mr';
const { domain = defaultDomain } = ctx.query;
- const rootUrl = getRootUrl(domain, ctx);
+ const rootUrl = getRootUrl(domain);
const currentUrl = `${rootUrl}/search/${option}${category === 'all' ? '' : `/${category}`}${keyword ? `?search_query=${keyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`;
diff --git a/lib/v2/18comic/utils.js b/lib/v2/18comic/utils.js
index 19c75b066..d389a476c 100644
--- a/lib/v2/18comic/utils.js
+++ b/lib/v2/18comic/utils.js
@@ -1,17 +1,17 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
-const config = require('@/config').value;
+import { config } from '@/config';
const defaultDomain = 'jmcomic1.me';
// list of address: https://jmcomic2.bet
const allowDomain = new Set(['18comic.vip', '18comic.org', 'jmcomic.me', 'jmcomic1.me', 'jm-comic3.art', 'jm-comic.club', 'jm-comic2.ark']);
-const getRootUrl = (domain, ctx) => {
+const getRootUrl = (domain) => {
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.has(domain)) {
- ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
+ throw new Error(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
return `https://${domain}`;
@@ -25,10 +25,10 @@ module.exports = {
const response = await got(currentUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.video-title')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 20)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20)
.toArray()
.map((item) => {
item = $(item);
@@ -45,7 +45,7 @@ module.exports = {
ctx.cache.tryGet(item.guid, async () => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.pubDate = parseDate(content('div[itemprop="datePublished"]').first().attr('content'));
item.category = content('span[data-type="tags"]')
diff --git a/lib/v2/19lou/index.js b/lib/v2/19lou/index.js
index d4b5b6940..24f477f92 100644
--- a/lib/v2/19lou/index.js
+++ b/lib/v2/19lou/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const iconv = require('iconv-lite');
const { isValidHost } = require('@/utils/valid-host');
@@ -15,7 +15,7 @@ const setCookie = function (cookieName, cookieValue, seconds, path, domain, secu
};
module.exports = async (ctx) => {
- const city = ctx.params.city ?? 'www';
+ const city = ctx.req.param('city') ?? 'www';
if (!isValidHost(city)) {
throw new Error('Invalid city');
}
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
+ const $ = load(iconv.decode(response.data, 'gbk'));
$('.title-more').remove();
@@ -57,7 +57,7 @@ module.exports = async (ctx) => {
},
});
- const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
+ const content = load(iconv.decode(detailResponse.data, 'gbk'));
content('.name-lz, .postView-pk-mod').remove();
@@ -70,9 +70,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text().split('-')[0],
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/1lou/index.js b/lib/v2/1lou/index.js
index 37a6a0b5b..2d19e29cb 100644
--- a/lib/v2/1lou/index.js
+++ b/lib/v2/1lou/index.js
@@ -1,17 +1,17 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const path = ctx.params.path ?? '';
+ const path = ctx.req.param('path') ?? '';
const rootUrl = `https://www.1lou.me`;
const currentUrl = `${rootUrl}/${path}`;
const response = await got({
method: 'get',
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('li.media.thread.tap:not(.hidden-sm)')
.toArray()
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.message.break-all').html();
const torrents = content('.attachlist').find('a');
if (torrents.length > 0) {
@@ -45,9 +45,9 @@ module.exports = async (ctx) => {
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '1Lou',
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/1point3acres/blog.js b/lib/v2/1point3acres/blog.js
index b1dae7861..06437abf1 100644
--- a/lib/v2/1point3acres/blog.js
+++ b/lib/v2/1point3acres/blog.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const categoryMap = {
@@ -37,12 +37,12 @@ module.exports = async (ctx) => {
const { data } = await got(`${rootUrl}/wp-json/wp/v2/posts`, {
searchParams: {
categories: category ? categoryMap[category].id : undefined,
- per_page: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 100,
+ per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100,
},
});
const items = data.map((item) => {
- const $ = cheerio.load(item.content.rendered, null, false);
+ const $ = load(item.content.rendered, null, false);
$('h2').nextAll().remove();
$('[powered-by="1p3a"], h2').remove();
$('img').each((_, img) => {
@@ -59,9 +59,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${category ? `${categoryMap[category].title} | ` : ''}美国留学就业生活攻略`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/1point3acres/category.js b/lib/v2/1point3acres/category.js
index 1603a4964..8c156c7bb 100644
--- a/lib/v2/1point3acres/category.js
+++ b/lib/v2/1point3acres/category.js
@@ -1,17 +1,17 @@
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
- const type = ctx.params.type ?? 'hot';
- const order = ctx.params.order ?? '';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10;
+ const id = ctx.req.param('id') ?? '';
+ const type = ctx.req.param('type') ?? 'hot';
+ const order = ctx.req.param('order') ?? '';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10;
const currentUrl = `${rootUrl}${id ? `/category/${id}` : ''}`;
const apiUrl = `${apiRootUrl}/api${id ? `/tags/${id}/` : ''}threads?type=${type}&includes=tags,forum_name,summary&ps=${limit}&pg=1&order=${order === '' ? '' : 'time_desc'}&is_groupid=1`;
- ctx.state.data = {
+ ctx.set('data', {
title: `一亩三分地 - ${id}${types[type]}`,
link: currentUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
- };
+ });
};
diff --git a/lib/v2/1point3acres/offer.js b/lib/v2/1point3acres/offer.js
index afaee70ff..6d8d49acb 100644
--- a/lib/v2/1point3acres/offer.js
+++ b/lib/v2/1point3acres/offer.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
+import { parseDate } from '@/utils/parse-date';
const path = require('path');
module.exports = async (ctx) => {
@@ -53,7 +53,7 @@ module.exports = async (ctx) => {
// },
// });
// const tid = responseBasic_1.data.background.tid;
- ctx.state.data = {
+ ctx.set('data', {
title: '录取结果 - 一亩三分地',
link: 'https://offer.1point3acres.com',
item: data.map((item) => ({
@@ -65,5 +65,5 @@ module.exports = async (ctx) => {
link: 'https://offer.1point3acres.com',
guid: `1point3acres:offer:${year}:${major}:${school}:${item.id}`,
})),
- };
+ });
};
diff --git a/lib/v2/1point3acres/section.js b/lib/v2/1point3acres/section.js
index dcb0526e1..1a0ca2072 100644
--- a/lib/v2/1point3acres/section.js
+++ b/lib/v2/1point3acres/section.js
@@ -12,17 +12,17 @@ const sections = {
};
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
- const type = ctx.params.type ?? 'hot';
- const order = ctx.params.order ?? '';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10;
+ const id = ctx.req.param('id') ?? '';
+ const type = ctx.req.param('type') ?? 'hot';
+ const order = ctx.req.param('order') ?? '';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10;
const currentUrl = `${rootUrl}${id ? (isNaN(id) ? `/category/${id}` : `/section/${id}`) : ''}`;
const apiUrl = `${apiRootUrl}/api${id ? (isNaN(id) ? `/tags/${id}/` : `/forums/${id}/`) : ''}threads?type=${type}&includes=tags,forum_name,summary&ps=${limit}&pg=1&order=${order === '' ? '' : 'time_desc'}&is_groupid=1`;
- ctx.state.data = {
+ ctx.set('data', {
title: `一亩三分地 - ${Object.hasOwn(sections, id) ? sections[id] : id}${types[type]}`,
link: currentUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
- };
+ });
};
diff --git a/lib/v2/1point3acres/thread.js b/lib/v2/1point3acres/thread.js
index 6677bc0a8..0b9d30136 100644
--- a/lib/v2/1point3acres/thread.js
+++ b/lib/v2/1point3acres/thread.js
@@ -1,15 +1,15 @@
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
- const type = ctx.params.type ?? 'hot';
- const order = ctx.params.order ?? '';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10;
+ const type = ctx.req.param('type') ?? 'hot';
+ const order = ctx.req.param('order') ?? '';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10;
const apiUrl = `${apiRootUrl}/api/threads?type=${type}&includes=tags,forum_name,summary&ps=${limit}&pg=1&order=${order === '' ? '' : 'time_desc'}&is_groupid=1`;
- ctx.state.data = {
+ ctx.set('data', {
title: `一亩三分地 - ${types[type]}`,
link: rootUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
- };
+ });
};
diff --git a/lib/v2/1point3acres/user/post.js b/lib/v2/1point3acres/user/post.js
index 6f72157fa..47e08841c 100644
--- a/lib/v2/1point3acres/user/post.js
+++ b/lib/v2/1point3acres/user/post.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
const { id } = ctx.params;
@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const { posts } = (await got.get(`https://instant.1point3acres.com/v2/api/user/post?pg=1&ps=10&user_id=${id}`)).data;
const [{ author_name: author }] = posts;
- ctx.state.data = {
+ ctx.set('data', {
title: `${author}的回复 - 一亩三分地`,
link: `https://instant.1point3acres.com/profile/${id}`,
description: `${author}的回复 - 一亩三分地`,
@@ -17,5 +17,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.create_time + ' GMT+8').toUTCString(),
link: `https://instant.1point3acres.com/thread/${item.thread_id}/post/${item.id}`,
})),
- };
+ });
};
diff --git a/lib/v2/1point3acres/user/thread.js b/lib/v2/1point3acres/user/thread.js
index fc55ede5d..e23d66e42 100644
--- a/lib/v2/1point3acres/user/thread.js
+++ b/lib/v2/1point3acres/user/thread.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
const { id } = ctx.params;
@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const { threads } = (await got.get(`https://instant.1point3acres.com/v2/api/user/thread?pg=1&ps=10&user_id=${id}`)).data;
const [{ author_name: author }] = threads;
- ctx.state.data = {
+ ctx.set('data', {
title: `${author}的主题帖 - 一亩三分地`,
link: `https://instant.1point3acres.com/profile/${id}`,
description: `${author}的主题帖 - 一亩三分地`,
@@ -17,5 +17,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.update_time + ' GMT+8').toUTCString(),
link: `https://instant.1point3acres.com/thread/${item.id}`,
})),
- };
+ });
};
diff --git a/lib/v2/1point3acres/utils.js b/lib/v2/1point3acres/utils.js
index addbf92be..c7baaf411 100644
--- a/lib/v2/1point3acres/utils.js
+++ b/lib/v2/1point3acres/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const bbcode = require('bbcodejs');
diff --git a/lib/v2/2048/index.js b/lib/v2/2048/index.js
index 9761e6bdc..2ef06f643 100644
--- a/lib/v2/2048/index.js
+++ b/lib/v2/2048/index.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '2';
+ const id = ctx.req.param('id') ?? '2';
const rootUrl = 'https://hjd2048.com';
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
accept: '*/*',
},
});
- const $ = cheerio.load(response);
+ const $ = load(response);
return $('ul li a')
.toArray()
.find((item) => $(item).text() === '最新線路1').attribs.href;
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const currentHost = `https://${new URL(response.url).host}`; // redirected host
$('#shortcut').remove();
@@ -58,7 +58,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.ads, .tips').remove();
@@ -77,7 +77,7 @@ module.exports = async (ctx) => {
url: downloadLink.text(),
});
- const torrent = cheerio.load(torrentResponse.data);
+ const torrent = load(torrentResponse.data);
item.enclosure_type = 'application/x-bittorrent';
item.enclosure_url = `https://data.datapps.org/${torrent('.uk-button').last().attr('href')}`;
@@ -105,9 +105,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('#main #breadCrumb a').last().text()} - 2048核基地`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/2cycd/index.js b/lib/v2/2cycd/index.js
index 95f7fce36..d0f2affa1 100644
--- a/lib/v2/2cycd/index.js
+++ b/lib/v2/2cycd/index.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const iconv = require('iconv-lite');
// http://www.2cycd.com/forum.php?mod=forumdisplay&fid=43&orderby=dateline
module.exports = async (ctx) => {
- const fid = ctx.params.fid ?? '43';
- const sort = ctx.params.sort ?? 'dateline';
+ const fid = ctx.req.param('fid') ?? '43';
+ const sort = ctx.req.param('sort') ?? 'dateline';
const rootUrl = 'http://www.2cycd.com/forum.php?mod=forumdisplay';
const currentUrl = `${rootUrl}&fid=${fid}&orderby=${sort}`;
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
+ const $ = load(iconv.decode(response.data, 'gbk'));
const list = $('tbody[id^="normalthread_"]')
.map((_, item) => {
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
+ const content = load(iconv.decode(detailResponse.data, 'gbk'));
const first_post = content('td[id^="postmessage_"]').first();
const dateobj = content('em[id^="authorposton"]').first();
item.description = first_post.html();
@@ -49,9 +49,9 @@ module.exports = async (ctx) => {
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/36kr/hot-list.js b/lib/v2/36kr/hot-list.js
index fdd182892..b76d0eeb7 100644
--- a/lib/v2/36kr/hot-list.js
+++ b/lib/v2/36kr/hot-list.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const { rootUrl, ProcessItem } = require('./utils');
@@ -23,7 +23,7 @@ const categories = {
};
module.exports = async (ctx) => {
- const category = ctx.params.category ?? '24';
+ const category = ctx.req.param('category') ?? '24';
const currentUrl = category === '24' ? rootUrl : `${rootUrl}/hot-list/catalog`;
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
const data = getProperty(JSON.parse(response.data.match(/window.initialState=({.*})/)[1]), categories[category].key);
let items = data
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10)
.filter((item) => item.itemType !== 0)
.map((item) => {
item = item.templateMaterial ?? item;
@@ -51,9 +51,9 @@ module.exports = async (ctx) => {
items = await Promise.all(items.map((item) => ProcessItem(item, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title: `36氪 - ${categories[category].title}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/36kr/index.js b/lib/v2/36kr/index.js
index e48699fe0..7f80b5889 100644
--- a/lib/v2/36kr/index.js
+++ b/lib/v2/36kr/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const { rootUrl, ProcessItem } = require('./utils');
@@ -23,12 +23,12 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const data = JSON.parse(response.data.match(/"itemList":(\[.*?])/)[1]);
let items = data
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 30)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 30)
.filter((item) => item.itemType !== 0)
.map((item) => {
item = item.templateMaterial ?? item;
@@ -45,9 +45,9 @@ module.exports = async (ctx) => {
items = await Promise.all(items.map((item) => ProcessItem(item, ctx.cache.tryGet)));
}
- ctx.state.data = {
+ ctx.set('data', {
title: `36氪 - ${$('title').text().split('_')[0]}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/36kr/utils.js b/lib/v2/36kr/utils.js
index 114e477c8..26ca7b947 100644
--- a/lib/v2/36kr/utils.js
+++ b/lib/v2/36kr/utils.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const CryptoJS = require('crypto-js');
const rootUrl = 'https://www.36kr.com';
@@ -16,7 +16,7 @@ module.exports = {
const cipherTextList = detailResponse.data.match(/{"state":"(.*)","isEncrypt":true}/) ?? [];
if (cipherTextList.length === 0) {
- const $ = cheerio.load(detailResponse.body);
+ const $ = load(detailResponse.body);
item.description = $('div.articleDetailContent').html();
} else {
const key = CryptoJS.enc.Utf8.parse('efabccee-b754-4c');
diff --git a/lib/v2/3dmgame/game.js b/lib/v2/3dmgame/game.js
index 3345b9fc7..438396cfb 100644
--- a/lib/v2/3dmgame/game.js
+++ b/lib/v2/3dmgame/game.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const { parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const url = `https://www.3dmgame.com/games/${name}/${type}/`;
const { data: response } = await got(url);
- const $ = cheerio.load(response);
+ const $ = load(response);
const listSelector = type === 'resource' ? $('.ZQ_Left .Llis_4 .lis li, .zq_left .rigtbox7 li').toArray() : $('.ZQ_Left .lis, .zq_left .newsleft li').toArray();
const list = listSelector.map((i) => {
@@ -25,10 +25,10 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text().split('_')[0],
description: $('head meta[name="Description"]').attr('content'),
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/3dmgame/news-center.js b/lib/v2/3dmgame/news-center.js
index bfb8a60c2..6cc910ba0 100644
--- a/lib/v2/3dmgame/news-center.js
+++ b/lib/v2/3dmgame/news-center.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const { parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const isArcPost = category && !isNaN(category); // https://www.3dmgame.com/news/\d+/
const url = `https://www.3dmgame.com/${category && category !== 'news_36_1' ? 'news/' : ''}${category ?? 'news'}/`;
const res = await got(url);
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const list = $(isArcPost ? '.selectarcpost' : '.selectpost')
.toArray()
.map((item) => {
@@ -33,10 +33,10 @@ module.exports = async (ctx) => {
const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title: '3DM - ' + $('title').text().split('_')[0],
description: $('meta[name="Description"]').attr('content'),
link: url,
item: out,
- };
+ });
};
diff --git a/lib/v2/3dmgame/utils.js b/lib/v2/3dmgame/utils.js
index f8ab79569..3f236fee4 100644
--- a/lib/v2/3dmgame/utils.js
+++ b/lib/v2/3dmgame/utils.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const parseArticle = (item, tryGet) =>
tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
if (item.link.startsWith('https://dl.3dmgame.com/')) {
const lis = $('.patchtop .lis');
diff --git a/lib/v2/423down/index.js b/lib/v2/423down/index.js
index 849da2e1f..aed9cc267 100644
--- a/lib/v2/423down/index.js
+++ b/lib/v2/423down/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const rootUrl = 'https://www.423down.com';
@@ -70,7 +70,7 @@ module.exports = async (ctx) => {
const url = `${rootUrl}/${categeoryMap[category][type]}`;
const response = await got.get(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('div.content-wrap > div > ul > li > a')
.filter((_, item) => {
const notAnotherWebPage = $(item).attr('style') !== 'display: none !important;';
@@ -85,7 +85,7 @@ module.exports = async (ctx) => {
list.map(async (item) => {
item = await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
- const $ = cheerio.load(detailResponse.data);
+ const $ = load(detailResponse.data);
const title = $('div.content-wrap > div > div.meta > h1 > a').text();
const pageContent = $('div.content-wrap > div > div.entry').html();
@@ -106,9 +106,9 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `423down-${titleMap[category][type]}`,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/4gamers/category.js b/lib/v2/4gamers/category.js
index 7e23990e7..ebd3cf488 100644
--- a/lib/v2/4gamers/category.js
+++ b/lib/v2/4gamers/category.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const { parseList, parseItem, getCategories } = require('./utils');
module.exports = async (ctx) => {
const { category } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 25;
const isLatest = !category;
const { data: response } = await got(`https://www.4gamers.com.tw/site/api/news/${isLatest ? 'latest' : `by-category/${category}`}`, {
@@ -23,9 +23,9 @@ module.exports = async (ctx) => {
categoryName = categories.find((c) => c.id === Number.parseInt(category)).name;
}
- ctx.state.data = {
+ ctx.set('data', {
title: `4Gamers - ${categoryName}`,
link: `https://www.4gamers.com.tw/news${isLatest ? '' : `/category/${category}/${categoryName}`}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/4gamers/tag.js b/lib/v2/4gamers/tag.js
index 8a85bd604..4182f2f89 100644
--- a/lib/v2/4gamers/tag.js
+++ b/lib/v2/4gamers/tag.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const { parseList, parseItem } = require('./utils');
module.exports = async (ctx) => {
const { tag } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 25;
const { data: response } = await got(`https://www.4gamers.com.tw/site/api/news/by-tag`, {
searchParams: {
@@ -15,9 +15,9 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
- ctx.state.data = {
+ ctx.set('data', {
title: `4Gamers - #${tag}`,
link: `https://www.4gamers.com.tw/news/tag/${tag}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/4gamers/topic.js b/lib/v2/4gamers/topic.js
index cf9a8cfb9..9c8cb062f 100644
--- a/lib/v2/4gamers/topic.js
+++ b/lib/v2/4gamers/topic.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const { parseList, parseItem } = require('./utils');
module.exports = async (ctx) => {
const { topic } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 25;
const { data: response } = await got(`https://www.4gamers.com.tw/site/api/news/option-cfg/${topic}`, {
searchParams: {
@@ -14,9 +14,9 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
- ctx.state.data = {
+ ctx.set('data', {
title: `4Gamers - ${topic}`,
link: `https://www.4gamers.com.tw/news/option-cfg/${topic}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/4gamers/utils.js b/lib/v2/4gamers/utils.js
index ebcf0c5bf..df3384edc 100644
--- a/lib/v2/4gamers/utils.js
+++ b/lib/v2/4gamers/utils.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const path = require('path');
-const { art } = require('@/utils/render');
-const { parseDate } = require('@/utils/parse-date');
+import { art } from '@/utils/render';
+import { parseDate } from '@/utils/parse-date';
const getCategories = (tryGet) =>
tryGet('4gamers:categories', async () => {
diff --git a/lib/v2/4ksj/forum.js b/lib/v2/4ksj/forum.js
index 74353a999..1c5cc9c21 100644
--- a/lib/v2/4ksj/forum.js
+++ b/lib/v2/4ksj/forum.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '2-1';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25;
+ const id = ctx.req.param('id') ?? '2-1';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 25;
const rootUrl = 'https://www.4ksj.com';
const currentUrl = `${rootUrl}/forum-${id}.html`;
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
+ const $ = load(iconv.decode(response.data, 'gbk'));
let items = $('div.nex_cmo_piv a')
.slice(0, limit)
@@ -41,7 +41,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
+ const content = load(iconv.decode(detailResponse.data, 'gbk'));
const details = {};
const links = {};
@@ -104,12 +104,12 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `4k世界 - ${$('#fontsearch ul.cl li.a')
.toArray()
.map((a) => $(a).text())
.join('+')}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/500px/tribe-set.js b/lib/v2/500px/tribe-set.js
index 5f62fb291..4bea85a00 100644
--- a/lib/v2/500px/tribe-set.js
+++ b/lib/v2/500px/tribe-set.js
@@ -1,12 +1,12 @@
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const { baseUrl, getTribeDetail, getTribeSets } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const limit = Number.parseInt(ctx.query.limit) || 100;
+ const limit = Number.parseInt(ctx.req.query('limit')) || 100;
const { tribe } = await getTribeDetail(id, ctx.cache.tryGet);
const tribeSets = await getTribeSets(id, limit, ctx.cache.tryGet);
@@ -19,11 +19,11 @@ module.exports = async (ctx) => {
link: `${baseUrl}/community/set/${item.id}/details`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: tribe.name,
description: `${tribe.watchword} - ${tribe.introduce}`,
link: `${baseUrl}/page/tribe/detail?tribeId=${id}&pagev=set`,
image: tribe.avatar.a1,
item: items,
- };
+ });
};
diff --git a/lib/v2/500px/user.js b/lib/v2/500px/user.js
index 4fb48c138..b98865526 100644
--- a/lib/v2/500px/user.js
+++ b/lib/v2/500px/user.js
@@ -1,11 +1,11 @@
-const { art } = require('@/utils/render');
-const { parseDate } = require('@/utils/parse-date');
+import { art } from '@/utils/render';
+import { parseDate } from '@/utils/parse-date';
const path = require('path');
const { baseUrl, getUserInfoFromUsername, getUserInfoFromId, getUserWorks } = require('./utils');
module.exports = async (ctx) => {
let { id } = ctx.params;
- const limit = Number.parseInt(ctx.query.limit) || 100;
+ const limit = Number.parseInt(ctx.req.query('limit')) || 100;
if (id.length !== 33) {
id = (await getUserInfoFromUsername(id, ctx.cache.tryGet)).id;
@@ -22,11 +22,11 @@ module.exports = async (ctx) => {
link: `${baseUrl}/community/photo-details/${item.id}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: userInfo.nickName,
description: userInfo.about,
image: userInfo.avatar.a1,
link: `${baseUrl}/${id}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/500px/utils.js b/lib/v2/500px/utils.js
index 56f5fb48e..7df6bfa22 100644
--- a/lib/v2/500px/utils.js
+++ b/lib/v2/500px/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { config } from '@/config';
const baseUrl = 'https://500px.com.cn';
@@ -27,7 +27,7 @@ const headers = {
const getUserInfoFromUsername = (username, tryGet) =>
tryGet(`500px:user:${username}`, async () => {
const { data } = await got(`${baseUrl}/${username}`);
- const $ = cheerio.load(data);
+ const $ = load(data);
return JSON.parse(
$('script[type="text/javascript"]')
.text()
diff --git a/lib/v2/50forum/zhuanjia.js b/lib/v2/50forum/zhuanjia.js
index 236ec4c32..59e461062 100644
--- a/lib/v2/50forum/zhuanjia.js
+++ b/lib/v2/50forum/zhuanjia.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const rootUrl = 'http://www.50forum.org.cn';
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
if (!data) {
return;
}
- const $ = cheerio.load(data);
+ const $ = load(data);
let out = $('div.container div.list_list.mtop10 ul li')
.find('a')
.toArray()
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const result = await got(item.link);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
item.description = $('div.list_content').html();
item.pubDate = timezone(parseDate($('span#publish_time').text(), 'YYYY-MM-DD HH:mm'), +8);
@@ -42,10 +42,10 @@ module.exports = async (ctx) => {
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国经济50人论坛专家文章`,
link: 'http://www.50forum.org.cn/home/article/index/category/zhuanjia.html',
description: '中国经济50人论坛专家文章',
item: out,
- };
+ });
};
diff --git a/lib/v2/52hrtt/index.js b/lib/v2/52hrtt/index.js
index 9bb7fc98c..7264fd4c8 100644
--- a/lib/v2/52hrtt/index.js
+++ b/lib/v2/52hrtt/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const area = ctx.params.area ?? 'global';
- const type = ctx.params.type ?? '';
+ const area = ctx.req.param('area') ?? 'global';
+ const type = ctx.req.param('type') ?? '';
const rootUrl = 'https://www.52hrtt.com';
const currentUrl = `${rootUrl}/${area}/n/w${type ? `?infoTypeId=${type}` : ''}`;
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(titleResponse.data);
+ const $ = load(titleResponse.data);
const list = response.data.data.infosMap.infoList
.filter((item) => item.infoTitle)
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.info-content').html();
@@ -48,9 +48,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${response.data.data.area.areaName} - ${$('.router-link-active').eq(0).text()} - 华人头条`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/52hrtt/symposium.js b/lib/v2/52hrtt/symposium.js
index 8122c1d44..c8eee38e9 100644
--- a/lib/v2/52hrtt/symposium.js
+++ b/lib/v2/52hrtt/symposium.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
- const classId = ctx.params.classId ?? '';
+ const id = ctx.req.param('id') ?? '';
+ const classId = ctx.req.param('classId') ?? '';
const rootUrl = 'https://www.52hrtt.com';
const currentUrl = `${rootUrl}/global/n/w/symposium/${id}`;
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(titleResponse.data);
+ const $ = load(titleResponse.data);
const list = response.data.data
.filter((item) => item.infoTitle)
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.info-content').html();
@@ -48,9 +48,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/56kog/class.js b/lib/v2/56kog/class.js
index b3e0b678e..49d3ade66 100644
--- a/lib/v2/56kog/class.js
+++ b/lib/v2/56kog/class.js
@@ -2,7 +2,7 @@ const { rootUrl, fetchItems } = require('./util');
module.exports = async (ctx) => {
const { category = '1_1' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const currentUrl = new URL(`class/${category}.html`, rootUrl).href;
diff --git a/lib/v2/56kog/top.js b/lib/v2/56kog/top.js
index fa90ff4a5..c8840d210 100644
--- a/lib/v2/56kog/top.js
+++ b/lib/v2/56kog/top.js
@@ -2,7 +2,7 @@ const { rootUrl, fetchItems } = require('./util');
module.exports = async (ctx) => {
const { category = 'weekvisit' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const currentUrl = new URL(`top/${category.split(/_/)[0]}_1.html`, rootUrl).href;
diff --git a/lib/v2/56kog/util.js b/lib/v2/56kog/util.js
index bacb4353e..5b0647c5d 100644
--- a/lib/v2/56kog/util.js
+++ b/lib/v2/56kog/util.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const rootUrl = 'https://www.56kog.com';
@@ -13,7 +13,7 @@ const fetchItems = async (limit, currentUrl, tryGet) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response, 'gbk'));
+ const $ = load(iconv.decode(response, 'gbk'));
let items = $('p.line')
.toArray()
@@ -37,7 +37,7 @@ const fetchItems = async (limit, currentUrl, tryGet) => {
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse, 'gbk'));
+ const content = load(iconv.decode(detailResponse, 'gbk'));
const details = content('div.mohe-content p')
.toArray()
diff --git a/lib/v2/591/list.js b/lib/v2/591/list.js
index 38eae088e..52b60d219 100644
--- a/lib/v2/591/list.js
+++ b/lib/v2/591/list.js
@@ -1,10 +1,10 @@
const path = require('path');
const { CookieJar } = require('tough-cookie');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const { isValidHost } = require('@/utils/valid-host');
const cookieJar = new CookieJar();
@@ -26,7 +26,7 @@ function appendRentalAPIParams(urlString) {
async function getToken() {
const html = await client('https://rent.591.com.tw').text();
- const $ = cheerio.load(html);
+ const $ = load(html);
const csrfToken = $('meta[name="csrf-token"]').attr('content');
if (!csrfToken) {
@@ -104,8 +104,8 @@ async function getHouseList(houseListURL) {
const renderHouse = (house) => art(path.join(__dirname, 'templates/house.art'), { house });
module.exports = async (ctx) => {
- const query = ctx.params.query ?? '';
- const country = ctx.params.country ?? 'tw';
+ const query = ctx.req.param('query') ?? '';
+ const country = ctx.req.param('country') ?? 'tw';
if (!isValidHost(country) && country !== 'tw') {
throw new Error('Invalid country codes. Only "tw" is supported now.');
@@ -131,14 +131,14 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: '591 租屋 - 自訂查詢',
link: queryUrl,
description: `591 租屋 - 自訂查詢, query: ${query}`,
item: items,
- };
+ });
- ctx.state.json = {
+ ctx.set('json', {
houses,
- };
+ });
};
diff --git a/lib/v2/5eplay/index.js b/lib/v2/5eplay/index.js
index fda633f71..59504c81e 100644
--- a/lib/v2/5eplay/index.js
+++ b/lib/v2/5eplay/index.js
@@ -1,8 +1,8 @@
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const zlib = require('zlib');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { config } from '@/config';
const { getAcwScV2ByArg1 } = require('./utils');
module.exports = async (ctx) => {
@@ -68,7 +68,7 @@ module.exports = async (ctx) => {
cookie: `acw_sc__v2=${acw_sc__v2}`,
},
});
- const $ = cheerio.load(detailResponse);
+ const $ = load(detailResponse);
const content = $('.article-text');
const res = [];
@@ -92,9 +92,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '5EPLAY',
link: 'https://csgo.5eplay.com/article',
item: items,
- };
+ });
};
diff --git a/lib/v2/6park/index.js b/lib/v2/6park/index.js
index cff146b67..9d1f5d36f 100644
--- a/lib/v2/6park/index.js
+++ b/lib/v2/6park/index.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? 'chan1';
- const type = ctx.params.type ?? '';
- const keyword = ctx.params.keyword ?? '';
+ const id = ctx.req.param('id') ?? 'chan1';
+ const type = ctx.req.param('type') ?? '';
+ const keyword = ctx.req.param('keyword') ?? '';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const rootUrl = 'https://club.6parkbbs.com';
const indexUrl = `${rootUrl}/${id}/index.php`;
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('#d_list ul li, #thread_list li, .t_l .t_subject')
.toArray()
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.title = content('title').text().replace(' -6park.com', '');
item.author = detailResponse.data.match(/送交者: .*>(.*)<.*\[/)[1];
@@ -57,9 +57,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/6park/news.js b/lib/v2/6park/news.js
index 7e4b462cc..aa4849f36 100644
--- a/lib/v2/6park/news.js
+++ b/lib/v2/6park/news.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const site = ctx.params.site ?? 'newspark';
- const id = ctx.params.id ?? '';
- const keyword = ctx.params.keyword ?? '';
+ const site = ctx.req.param('site') ?? 'newspark';
+ const id = ctx.req.param('id') ?? '';
+ const keyword = ctx.req.param('keyword') ?? '';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const isLocal = site === 'local';
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('#d_list ul li, #thread_list li, .t_l .t_subject')
.toArray()
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
const matches = detailResponse.data.match(/新闻来源:(.*?)于.*(\d{4}(?:-\d{2}){2} (?:\d{1,2}:){2}\d{1,2})/);
@@ -66,9 +66,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/6v123/latest-movies.js b/lib/v2/6v123/latest-movies.js
index b4aabb362..644e5112f 100644
--- a/lib/v2/6v123/latest-movies.js
+++ b/lib/v2/6v123/latest-movies.js
@@ -5,10 +5,10 @@ const baseURL = 'https://www.hao6v.cc/gvod/zx.html';
module.exports = async (ctx) => {
const item = await processItems(ctx, baseURL);
- ctx.state.data = {
+ ctx.set('data', {
title: '6v电影-最新电影',
link: baseURL,
description: '6v最新电影RSS',
item,
- };
+ });
};
diff --git a/lib/v2/6v123/latest-tvseries.js b/lib/v2/6v123/latest-tvseries.js
index f7a22e14b..151b5753f 100644
--- a/lib/v2/6v123/latest-tvseries.js
+++ b/lib/v2/6v123/latest-tvseries.js
@@ -5,10 +5,10 @@ const baseURL = 'https://www.hao6v.tv/gvod/dsj.html';
module.exports = async (ctx) => {
const item = await processItems(ctx, baseURL);
- ctx.state.data = {
+ ctx.set('data', {
title: '6v电影-最新电影',
link: baseURL,
description: '6v最新电影RSS',
item,
- };
+ });
};
diff --git a/lib/v2/6v123/utils.js b/lib/v2/6v123/utils.js
index 5c00d16d1..e5d0b05b3 100644
--- a/lib/v2/6v123/utils.js
+++ b/lib/v2/6v123/utils.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const iconv = require('iconv-lite');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const utils = {
loadDetailPage: async function loadDetailPage(link) {
@@ -11,7 +11,7 @@ const utils = {
});
response.data = iconv.decode(response.data, 'gb2312');
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const detailInfo = {
title: $('title')
@@ -34,7 +34,7 @@ const utils = {
});
response.data = iconv.decode(response.data, 'gb2312');
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('ul.list')[0].children;
const process = await Promise.all(
diff --git a/lib/v2/78dm/index.js b/lib/v2/78dm/index.js
index f58d2a715..5039397e4 100644
--- a/lib/v2/78dm/index.js
+++ b/lib/v2/78dm/index.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -14,10 +14,10 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.card-title')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 30)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 30)
.toArray()
.map((item) => {
item = $(item);
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.tag, .level').remove();
content('.lazy').each(function () {
@@ -66,9 +66,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `78动漫 - ${$('title').text().split('_')[0]} - ${$('.actived').first().text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/7mmtv/index.js b/lib/v2/7mmtv/index.js
index 929c735df..f75cfb6a8 100644
--- a/lib/v2/7mmtv/index.js
+++ b/lib/v2/7mmtv/index.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const language = ctx.params.language ?? 'en';
- const category = ctx.params.category ?? 'censored_list';
- const type = ctx.params.type ?? 'all';
+ const language = ctx.req.param('language') ?? 'en';
+ const category = ctx.req.param('category') ?? 'censored_list';
+ const type = ctx.req.param('type') ?? 'all';
const rootUrl = 'https://7mmtv.sx';
const currentUrl = `${rootUrl}/${language}/${category}/${type}/1.html`;
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.video')
.toArray()
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = art(path.join(__dirname, 'templates/description.art'), {
cover: content('.content_main_cover img').attr('src'),
@@ -67,12 +67,12 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title')
.text()
.replace(/ - Watch JAV Online/, ''),
link: currentUrl,
item: items,
description: $('meta[name="description"]').attr('content'),
- };
+ });
};
diff --git a/lib/v2/81/81rc/index.js b/lib/v2/81/81rc/index.js
index 85a8dfe02..585089cb0 100644
--- a/lib/v2/81/81rc/index.js
+++ b/lib/v2/81/81rc/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const thePath = ctx.path.replace(/^\/81rc/, '');
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const rootUrl = 'https://81rc.81.cn';
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
let items = $('div.left-news ul li a')
.slice(0, limit)
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
item.description = content('.txt').html();
item.author = content('meta[name="reporter"]').prop('content') || content('meta[name="author"]').prop('content');
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
const icon = $('link[rel="icon"]').prop('href');
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `军队人才网 - ${$('div.left-word')
.find('a')
@@ -58,5 +58,5 @@ module.exports = async (ctx) => {
language: 'zh-cn',
icon,
logo: icon,
- };
+ });
};
diff --git a/lib/v2/8264/list.js b/lib/v2/8264/list.js
index 82b31c76a..2cb47525d 100644
--- a/lib/v2/8264/list.js
+++ b/lib/v2/8264/list.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
const { id = '751' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const rootUrl = 'https://www.8264.com';
const currentUrl = new URL(`list/${id}`, rootUrl).href;
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response, 'gbk'));
+ const $ = load(iconv.decode(response, 'gbk'));
$('div.newslist_info').remove();
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse, 'gbk'));
+ const content = load(iconv.decode(detailResponse, 'gbk'));
content('a.syq, a.xlsj, a.titleoverflow200, #fjump').remove();
content('i.pstatus').remove();
@@ -78,7 +78,7 @@ module.exports = async (ctx) => {
const description = $('meta[name="description"]').prop('content').trim();
const icon = new URL('favicon', rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `${$('span.country, h2').text()} - ${description.split(',').pop()}`,
link: currentUrl,
@@ -88,5 +88,5 @@ module.exports = async (ctx) => {
logo: icon,
subtitle: $('meta[name="keywords"]').prop('content').trim(),
author: $('meta[name="author"]').prop('content'),
- };
+ });
};
diff --git a/lib/v2/8kcos/article.js b/lib/v2/8kcos/article.js
index aa371d691..300c8e453 100644
--- a/lib/v2/8kcos/article.js
+++ b/lib/v2/8kcos/article.js
@@ -1,10 +1,10 @@
-const Cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
async function loadArticle(link) {
const resp = await got(link);
- const article = Cheerio.load(resp.body);
+ const article = load(resp.body);
const entryChildren = article('div.entry-content').children();
const imgs = entryChildren
.find('noscript')
@@ -13,7 +13,7 @@ async function loadArticle(link) {
const txt = entryChildren
.slice(2)
.toArray()
- .map((e) => Cheerio.load(e).html());
+ .map((e) => load(e).html());
return {
title: article('.entry-title').text(),
description: [...imgs, ...txt].join(''),
diff --git a/lib/v2/8kcos/cat.js b/lib/v2/8kcos/cat.js
index 744379c22..7a4555274 100644
--- a/lib/v2/8kcos/cat.js
+++ b/lib/v2/8kcos/cat.js
@@ -1,22 +1,22 @@
-const got = require('@/utils/got');
-const Cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
const loadArticle = require('./article');
module.exports = async (ctx) => {
- const limit = Number.parseInt(ctx.query.limit);
+ const limit = Number.parseInt(ctx.req.query('limit'));
const { cat = '8kasianidol' } = ctx.params;
const url = `${SUB_URL}category/${cat}/`;
const resp = await got(url);
- const $ = Cheerio.load(resp.body);
+ const $ = load(resp.body);
const itemRaw = $('li.item').toArray();
- ctx.state.data = {
+ ctx.set('data', {
title: `${SUB_NAME_PREFIX}-${$('span[property=name]:not(.hide)').text()}`,
link: url,
item: await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
- const { href } = Cheerio.load(e)('h2 > a')[0].attribs;
+ const { href } = load(e)('h2 > a')[0].attribs;
return ctx.cache.tryGet(href, () => loadArticle(href));
})
),
- };
+ });
};
diff --git a/lib/v2/8kcos/latest.js b/lib/v2/8kcos/latest.js
index 1b7fc15c1..a569ca871 100644
--- a/lib/v2/8kcos/latest.js
+++ b/lib/v2/8kcos/latest.js
@@ -1,23 +1,23 @@
-const got = require('@/utils/got');
-const Cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
const loadArticle = require('./article');
const url = SUB_URL;
module.exports = async (ctx) => {
- const limit = Number.parseInt(ctx.query.limit);
+ const limit = Number.parseInt(ctx.req.query('limit'));
const response = await got(url);
- const itemRaw = Cheerio.load(response.body)('ul.post-loop li.item').toArray();
- ctx.state.data = {
+ const itemRaw = load(response.body)('ul.post-loop li.item').toArray();
+ ctx.set('data', {
title: `${SUB_NAME_PREFIX}-最新`,
link: url,
item:
response.body &&
(await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
- const { href } = Cheerio.load(e)('h2 > a')[0].attribs;
+ const { href } = load(e)('h2 > a')[0].attribs;
return ctx.cache.tryGet(href, () => loadArticle(href));
})
)),
- };
+ });
};
diff --git a/lib/v2/8kcos/tag.js b/lib/v2/8kcos/tag.js
index 3930d50ed..1a48d3960 100644
--- a/lib/v2/8kcos/tag.js
+++ b/lib/v2/8kcos/tag.js
@@ -1,23 +1,23 @@
-const got = require('@/utils/got');
-const Cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
const loadArticle = require('./article');
module.exports = async (ctx) => {
- const limit = Number.parseInt(ctx.query.limit);
+ const limit = Number.parseInt(ctx.req.query('limit'));
const { tag } = ctx.params;
const url = `${SUB_URL}tag/${tag}/`;
const resp = await got(url);
- const $ = Cheerio.load(resp.body);
+ const $ = load(resp.body);
const itemRaw = $('li.item').toArray();
- ctx.state.data = {
+ ctx.set('data', {
title: `${SUB_NAME_PREFIX}-${$('span[property=name]:not(.hide)').text()}`,
link: url,
item: await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
- const { href } = Cheerio.load(e)('h2 > a')[0].attribs;
+ const { href } = load(e)('h2 > a')[0].attribs;
return ctx.cache.tryGet(href, () => loadArticle(href));
})
),
- };
+ });
};
diff --git a/lib/v2/8world/index.js b/lib/v2/8world/index.js
index 351b1dcd2..489ccb546 100644
--- a/lib/v2/8world/index.js
+++ b/lib/v2/8world/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const path = ctx.path === '/' ? '/realtime' : ctx.path;
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('div[data-column="Two-Third"] .article-title .article-link')
.toArray()
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.text-long').html();
item.title = content('meta[name="cXenseParse:mdc-title"]').attr('content');
@@ -49,9 +49,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/91porn/author.js b/lib/v2/91porn/author.js
index 8ea49ba29..ff8da9e35 100644
--- a/lib/v2/91porn/author.js
+++ b/lib/v2/91porn/author.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const { domainValidation } = require('./utils');
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const { domain = '91porn.com' } = ctx.query;
const { uid, lang = 'en_US' } = ctx.params;
const siteUrl = `https://${domain}/uvideos.php?UID=${uid}&type=public`;
- domainValidation(domain, ctx);
+ domainValidation(domain);
const response = await got.post(siteUrl, {
form: {
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.row .well')
.toArray()
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
items.map((item) =>
ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
- const $ = cheerio.load(data);
+ const $ = load(data);
item.pubDate = parseDate($('.title-yakov').eq(0).text(), 'YYYY-MM-DD');
item.description = art(path.join(__dirname, 'templates/index.art'), {
@@ -52,9 +52,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('.login_register_header').text()} - 91porn`,
link: siteUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/91porn/index.js b/lib/v2/91porn/index.js
index fdfd440b2..e58f9dab2 100644
--- a/lib/v2/91porn/index.js
+++ b/lib/v2/91porn/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const { domainValidation } = require('./utils');
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const { domain = '91porn.com' } = ctx.query;
const siteUrl = `https://${domain}/index.php`;
const { lang = 'en_US' } = ctx.params;
- domainValidation(domain, ctx);
+ domainValidation(domain);
const response = await got.post(siteUrl, {
form: {
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.row .well')
.toArray()
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
items.map((item) =>
ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
- const $ = cheerio.load(data);
+ const $ = load(data);
item.pubDate = parseDate($('.title-yakov').eq(0).text(), 'YYYY-MM-DD');
item.description = art(path.join(__dirname, 'templates/index.art'), {
@@ -52,9 +52,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('.login_register_header').text()} - 91porn`,
link: siteUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/91porn/utils.js b/lib/v2/91porn/utils.js
index 0e46a2378..592660886 100644
--- a/lib/v2/91porn/utils.js
+++ b/lib/v2/91porn/utils.js
@@ -1,9 +1,9 @@
-const config = require('@/config').value;
+import { config } from '@/config';
const allowDomain = new Set(['91porn.com', 'www.91porn.com', '0122.91p30.com', 'www.91zuixindizhi.com', 'w1218.91p46.com']);
-const domainValidation = (domain, ctx) => {
+const domainValidation = (domain) => {
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.has(domain)) {
- ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
+ throw new Error(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
};
diff --git a/lib/v2/95mm/category.js b/lib/v2/95mm/category.js
index 43baec875..c8c4913aa 100644
--- a/lib/v2/95mm/category.js
+++ b/lib/v2/95mm/category.js
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
11: '美女壁纸',
};
- const category = ctx.params.category;
+ const category = ctx.req.param('category');
const currentUrl = `${rootUrl}/category-${category}/list-1/index.html?page=1`;
diff --git a/lib/v2/95mm/tab.js b/lib/v2/95mm/tab.js
index 1e2dc42c1..bb58519e0 100644
--- a/lib/v2/95mm/tab.js
+++ b/lib/v2/95mm/tab.js
@@ -1,7 +1,7 @@
const { rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
- const tab = ctx.params.tab ?? '最新';
+ const tab = ctx.req.param('tab') ?? '最新';
const currentUrl = `${rootUrl}/home-ajax/index.html?tabcid=${tab}&page=1`;
diff --git a/lib/v2/95mm/tag.js b/lib/v2/95mm/tag.js
index d78463728..bccb9c2e9 100644
--- a/lib/v2/95mm/tag.js
+++ b/lib/v2/95mm/tag.js
@@ -1,7 +1,7 @@
const { rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
- const tag = ctx.params.tag;
+ const tag = ctx.req.param('tag');
const currentUrl = `${rootUrl}/tag-${tag}/page-1/index.html`;
diff --git a/lib/v2/95mm/utils.js b/lib/v2/95mm/utils.js
index dcdbd1701..014513352 100644
--- a/lib/v2/95mm/utils.js
+++ b/lib/v2/95mm/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
const rootUrl = 'https://www.95mm.vip';
@@ -16,7 +16,7 @@ module.exports = {
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('div.list-body')
.toArray()
diff --git a/lib/v2/9to5/subsite.js b/lib/v2/9to5/subsite.js
index fdd11ccad..77a3d2c06 100644
--- a/lib/v2/9to5/subsite.js
+++ b/lib/v2/9to5/subsite.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
const utils = require('./utils');
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
link,
description;
- switch (ctx.params.subsite) {
+ switch (ctx.req.param('subsite')) {
case 'mac':
link = 'https://9to5mac.com';
title += 'Mac';
@@ -30,9 +30,9 @@ module.exports = async (ctx) => {
break;
}
- if (ctx.params.tag) {
- link = `${link}/guides/${ctx.params.tag}/feed/`;
- title = `${ctx.params.tag} | ${title}`;
+ if (ctx.req.param('tag')) {
+ link = `${link}/guides/${ctx.req.param('tag')}/feed/`;
+ title = `${ctx.req.param('tag')} | ${title}`;
} else {
link = `${link}/feed/`;
}
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
const feed = await parser.parseURL(link);
const items = await Promise.all(
- feed.items.splice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10).map((item) =>
+ feed.items.splice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10).map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
@@ -61,10 +61,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title,
link,
description,
item: items,
- };
+ });
};
diff --git a/lib/v2/9to5/utils.js b/lib/v2/9to5/utils.js
index 328e1a8cf..2aa94e01c 100644
--- a/lib/v2/9to5/utils.js
+++ b/lib/v2/9to5/utils.js
@@ -1,7 +1,7 @@
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const ProcessFeed = (data) => {
- const $ = cheerio.load(data);
+ const $ = load(data);
const content = $('div.post-content');
const cover = $('meta[property="og:image"]');
diff --git a/lib/v2/aamacau/index.js b/lib/v2/aamacau/index.js
index 88fd3dad8..1faeca5a4 100644
--- a/lib/v2/aamacau/index.js
+++ b/lib/v2/aamacau/index.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'topics';
- const id = ctx.params.id ?? '';
+ const category = ctx.req.param('category') ?? 'topics';
+ const id = ctx.req.param('id') ?? '';
const rootUrl = 'https://aamacau.com';
const currentUrl = `${rootUrl}/${category === 'topics' ? 'topics/breakingnews' : `topics/${category}${id ? `/${id}` : ''}`}`;
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('post-title a')
.map((_, item) => {
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.cat, .author, .date').remove();
@@ -48,9 +48,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/abc/index.js b/lib/v2/abc/index.js
index b2f459128..2b0339034 100644
--- a/lib/v2/abc/index.js
+++ b/lib/v2/abc/index.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
const { category = 'news/justin' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const rootUrl = 'https://www.abc.net.au';
const apiUrl = new URL('news-web/api/loader/channelrefetch', rootUrl).href;
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- const $ = cheerio.load(currentResponse);
+ const $ = load(currentResponse);
documentId = documentId ?? $('div[data-uri^="coremedia://collection/"]').first().prop('data-uri').split(/\//).pop();
@@ -71,7 +71,7 @@ module.exports = async (ctx) => {
try {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
content('aside, header, [data-print="inline-media"], [data-component="EmbedBlock"]').remove();
@@ -145,7 +145,7 @@ module.exports = async (ctx) => {
const icon = new URL($('link[rel="apple-touch-icon"]').prop('href'), rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: $('title').first().text(),
link: currentUrl,
@@ -157,5 +157,5 @@ module.exports = async (ctx) => {
subtitle: $('meta[property="og:title"]').prop('content'),
author: $('meta[name="generator"]').prop('content'),
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/abmedia/category.js b/lib/v2/abmedia/category.js
index 06a3a4e3c..55f43ed81 100644
--- a/lib/v2/abmedia/category.js
+++ b/lib/v2/abmedia/category.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const rootUrl = 'https://www.abmedia.io';
const cateAPIUrl = `${rootUrl}/wp-json/wp/v2/categories`;
@@ -8,8 +8,8 @@ const postsAPIUrl = `${rootUrl}/wp-json/wp/v2/posts`;
const getCategoryId = (category) => got.get(`${cateAPIUrl}?slug=${category}`).then((res) => res.data[0].id);
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'technology-development';
- const limit = ctx.params.limit ?? 25;
+ const category = ctx.req.param('category') ?? 'technology-development';
+ const limit = ctx.req.param('limit') ?? 25;
const categoryId = await getCategoryId(category);
const response = await got.get(`${postsAPIUrl}?categories=${categoryId}&page=1&per_page=${limit}`);
@@ -22,9 +22,9 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.date),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `abmedia - ${category}`,
link: `${rootUrl}/category/${category}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/abmedia/index.js b/lib/v2/abmedia/index.js
index e6d5d341f..8baa7b7a6 100644
--- a/lib/v2/abmedia/index.js
+++ b/lib/v2/abmedia/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const rootUrl = 'https://www.abmedia.io';
const postsAPIUrl = `${rootUrl}/wp-json/wp/v2/posts`;
module.exports = async (ctx) => {
- const limit = ctx.params.limit ?? 10;
+ const limit = ctx.req.param('limit') ?? 10;
const url = `${postsAPIUrl}?per_page=${limit}`;
const response = await got.get(url);
@@ -18,9 +18,9 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.date),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'ABMedia - 最新消息',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/abskoop/index.js b/lib/v2/abskoop/index.js
index 222aa9338..53ffde703 100644
--- a/lib/v2/abskoop/index.js
+++ b/lib/v2/abskoop/index.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://www.ahhhhfs.com/wp-json/wp/v2/posts',
searchParams: {
- per_page: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10,
+ per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10,
_embed: '',
},
});
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
- const $detail = cheerio.load(detailResponse.data);
+ const $detail = load(detailResponse.data);
$detail('article.post-content').find('.lwptoc').remove();
$detail('article.post-content').find('#related_posts').remove();
$detail('article.post-content').find('.entry-copyright').remove();
@@ -37,11 +37,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: 'ahhhhfs-A姐分享',
link: 'https://www.ahhhhfs.com',
description:
'A姐分享,分享各种网络云盘资源、BT种子、高清电影电视剧和羊毛福利,收集各种有趣实用的软件和APP的下载、安装、使用方法,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注谷歌苹果等互联网最新的资讯动态,探索新领域,发现新美好,分享小快乐。',
item: items,
- };
+ });
};
diff --git a/lib/v2/abskoop/nsfw.js b/lib/v2/abskoop/nsfw.js
index 8187c73ba..ff7be9a1e 100644
--- a/lib/v2/abskoop/nsfw.js
+++ b/lib/v2/abskoop/nsfw.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://nsfw.abskoop.com/wp-json/wp/v2/posts',
searchParams: {
- per_page: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10,
+ per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10,
_embed: '',
},
});
@@ -21,11 +21,11 @@ module.exports = async (ctx) => {
category: [...new Set(item._embedded['wp:term'].flatMap((i) => i.map((j) => j.name)))],
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'ahhhhfs-A姐分享NSFW',
link: 'https://nsfw.ahhhhfs.com/articles-archive',
description:
'A姐分享NSFW,分享各种网络云盘资源、BT种子、磁力链接、高清电影电视剧和羊毛福利,收集各种有趣实用的软件和APP的下载、安装、使用方法,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注谷歌苹果等互联网最新的资讯动态,探索新领域,发现新美好,分享小快乐。',
item: list,
- };
+ });
};
diff --git a/lib/v2/acfun/article.js b/lib/v2/acfun/article.js
index ac1acd15a..2f1e029be 100644
--- a/lib/v2/acfun/article.js
+++ b/lib/v2/acfun/article.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://www.acfun.cn';
const categoryMap = {
@@ -76,7 +76,7 @@ module.exports = async (ctx) => {
referer: url,
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const articleInfo = $('.main script')
.text()
.match(/window.articleInfo = (.*);\n\s*window.likeDomain/)[1];
@@ -92,9 +92,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: categoryMap[categoryId].title,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/acfun/bangumi.js b/lib/v2/acfun/bangumi.js
index 6a8e0813a..8e48e3ad1 100644
--- a/lib/v2/acfun/bangumi.js
+++ b/lib/v2/acfun/bangumi.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { id } = ctx.params;
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
const bangumiData = JSON.parse(bangumiPage.data.match(/window.bangumiData = (.*?);\n/)[1]);
const bangumiList = JSON.parse(bangumiPage.data.match(/window.bangumiList = (.*?);\n/)[1]);
- ctx.state.data = {
+ ctx.set('data', {
title: bangumiData.bangumiTitle,
link: url,
description: bangumiData.bangumiIntro,
@@ -24,5 +24,5 @@ module.exports = async (ctx) => {
link: `http://www.acfun.cn/bangumi/aa${id}_36188_${item.itemId}`,
pubDate: parseDate(item.updateTime, 'x'),
})),
- };
+ });
};
diff --git a/lib/v2/acfun/video.js b/lib/v2/acfun/video.js
index c7f91f97e..422838520 100644
--- a/lib/v2/acfun/video.js
+++ b/lib/v2/acfun/video.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
+ const uid = ctx.req.param('uid');
const url = `https://www.acfun.cn/u/${uid}`;
const host = 'https://www.acfun.cn';
const response = await got(url, {
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
});
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const title = $('title').text();
const description = $('.signature .complete').text();
const list = $('#ac-space-video-list a').get();
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
.text()
.match(/.user-photo{\n\s*background:url\((.*)\) 0% 0% \/ 100% no-repeat;/)[1];
- ctx.state.data = {
+ ctx.set('data', {
title,
link: url,
description,
@@ -41,5 +41,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(itemDate, 'YYYY/MM/DD'),
};
}),
- };
+ });
};
diff --git a/lib/v2/acg17/post.js b/lib/v2/acg17/post.js
index c5555a67a..d85ece4e7 100644
--- a/lib/v2/acg17/post.js
+++ b/lib/v2/acg17/post.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const host = 'http://acg17.com';
module.exports = async (ctx) => {
const response = await got(`${host}/wp-json/wp/v2/posts?per_page=30`);
const list = response.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `ACG17 - 全部文章`,
link: `${host}/blog`,
description: 'ACG17 - 全部文章',
@@ -16,5 +16,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.date_gmt),
description: item.content.rendered,
})),
- };
+ });
};
diff --git a/lib/v2/acpaa/index.js b/lib/v2/acpaa/index.js
index 398811e14..c4ea3d68f 100644
--- a/lib/v2/acpaa/index.js
+++ b/lib/v2/acpaa/index.js
@@ -1,18 +1,18 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { id = '1', name = '重要通知' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const rootUrl = 'http://www.acpaa.cn';
const currentUrl = new URL(`article/taglist.jhtml?tagIds=${id}&tagname=${name}`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
let items = $('div.text01 ul li a[title]')
.slice(0, limit)
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
item.title = content('div.xhjj_head01').text();
item.description = content('div.text01').html();
@@ -45,7 +45,7 @@ module.exports = async (ctx) => {
const author = $('title').text().replaceAll('-', '');
const subtitle = $('span.myTitle').text().trim();
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `${author} - ${subtitle}`,
link: currentUrl,
@@ -53,5 +53,5 @@ module.exports = async (ctx) => {
language: 'zh',
subtitle,
author,
- };
+ });
};
diff --git a/lib/v2/acs/journal.js b/lib/v2/acs/journal.js
index 575e175c3..3f408cb64 100644
--- a/lib/v2/acs/journal.js
+++ b/lib/v2/acs/journal.js
@@ -1,18 +1,19 @@
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
-const config = require('@/config').value;
+import { config } from '@/config';
+import puppeteer from '@/utils/puppeteer';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
+ const id = ctx.req.param('id') ?? '';
const rootUrl = 'https://pubs.acs.org';
const currentUrl = `${rootUrl}/toc/${id}/0/0`;
let title = '';
- const browser = await require('@/utils/puppeteer')();
+ const browser = await puppeteer();
const items = await ctx.cache.tryGet(
currentUrl,
async () => {
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const html = await page.evaluate(() => document.documentElement.innerHTML);
await page.close();
- const $ = cheerio.load(html);
+ const $ = load(html);
title = $('meta[property="og:title"]').attr('content');
@@ -65,9 +66,9 @@ module.exports = async (ctx) => {
await browser.close();
- ctx.state.data = {
+ ctx.set('data', {
title,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/aeaweb/index.js b/lib/v2/aeaweb/index.js
index 8d5c04da2..b84120f22 100644
--- a/lib/v2/aeaweb/index.js
+++ b/lib/v2/aeaweb/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- let id = ctx.params.id;
+ let id = ctx.req.param('id');
const rootUrl = 'https://www.aeaweb.org';
const currentUrl = `${rootUrl}/journals/${id}`;
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- let $ = cheerio.load(response.data);
+ let $ = load(response.data);
$('.read-more').remove();
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
url: searchUrl,
});
- $ = cheerio.load(response.data);
+ $ = load(response.data);
let items = $('h4.title a')
.toArray()
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.doi = content('meta[name="citation_doi"]').attr('content');
@@ -72,10 +72,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title,
description,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/aeon/category.js b/lib/v2/aeon/category.js
index 12a40dc20..800fcb458 100644
--- a/lib/v2/aeon/category.js
+++ b/lib/v2/aeon/category.js
@@ -1,11 +1,11 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
+import { load } from 'cheerio';
+import got from '@/utils/got';
const { getData } = require('./utils');
module.exports = async (ctx) => {
- const url = `https://aeon.co/${ctx.params.category}`;
+ const url = `https://aeon.co/${ctx.req.param('category')}`;
const { data: response } = await got(url);
- const $ = cheerio.load(response);
+ const $ = load(response);
const data = JSON.parse($('script#__NEXT_DATA__').text());
@@ -18,10 +18,10 @@ module.exports = async (ctx) => {
const items = await getData(ctx, list);
- ctx.state.data = {
+ ctx.set('data', {
title: `AEON | ${data.props.pageProps.section.title}`,
link: url,
description: data.props.pageProps.section.metaDescription,
item: items,
- };
+ });
};
diff --git a/lib/v2/aeon/type.js b/lib/v2/aeon/type.js
index 23877850b..a9e2fe51e 100644
--- a/lib/v2/aeon/type.js
+++ b/lib/v2/aeon/type.js
@@ -1,15 +1,15 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
+import { load } from 'cheerio';
+import got from '@/utils/got';
const { getData } = require('./utils');
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
const binaryType = type === 'videos' ? 'videos' : 'essays';
const capitalizedType = type.charAt(0).toUpperCase() + type.slice(1);
const url = `https://aeon.co/${type}`;
const { data: response } = await got(url);
- const $ = cheerio.load(response);
+ const $ = load(response);
const data = JSON.parse($('script#__NEXT_DATA__').text());
@@ -21,9 +21,9 @@ module.exports = async (ctx) => {
const items = await getData(ctx, list);
- ctx.state.data = {
+ ctx.set('data', {
title: `AEON | ${capitalizedType}`,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/aeon/utils.js b/lib/v2/aeon/utils.js
index 1e5316820..70ef01768 100644
--- a/lib/v2/aeon/utils.js
+++ b/lib/v2/aeon/utils.js
@@ -1,6 +1,6 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
const getData = async (ctx, list) => {
@@ -8,7 +8,7 @@ const getData = async (ctx, list) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const data = JSON.parse($('script#__NEXT_DATA__').text());
const type = data.props.pageProps.article.type.toLowerCase();
@@ -28,7 +28,7 @@ const getData = async (ctx, list) => {
item.author = data.props.pageProps.article.authors.map((author) => author.displayName).join(', ');
const article = data.props.pageProps.article;
- const capture = cheerio.load(article.body);
+ const capture = load(article.body);
const banner = article.thumbnail?.urls?.header;
capture('p.pullquote').remove();
diff --git a/lib/v2/agefans/detail.js b/lib/v2/agefans/detail.js
index b81ae156b..8e79ab53a 100644
--- a/lib/v2/agefans/detail.js
+++ b/lib/v2/agefans/detail.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { rootUrl } = require('./utils');
module.exports = async (ctx) => {
- const response = await got(`${rootUrl}/detail/${ctx.params.id}`);
- const $ = cheerio.load(response.data);
+ const response = await got(`${rootUrl}/detail/${ctx.req.param('id')}`);
+ const $ = load(response.data);
const ldJson = JSON.parse($('script[type="application/ld+json"]').text());
@@ -22,10 +22,10 @@ module.exports = async (ctx) => {
})
.reverse();
- ctx.state.data = {
+ ctx.set('data', {
title: `AGE动漫 - ${ldJson.name}`,
- link: `${rootUrl}/detail/${ctx.params.id}`,
+ link: `${rootUrl}/detail/${ctx.req.param('id')}`,
description: ldJson.description,
item: items,
- };
+ });
};
diff --git a/lib/v2/agefans/update.js b/lib/v2/agefans/update.js
index 03a9a1129..656255f47 100644
--- a/lib/v2/agefans/update.js
+++ b/lib/v2/agefans/update.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { rootUrl } = require('./utils');
module.exports = async (ctx) => {
const currentUrl = `${rootUrl}/update`;
const response = await got(currentUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.video_item')
.toArray()
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('img').each((_, ele) => {
if (ele.attribs['data-original']) {
@@ -41,9 +41,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/agirls/index.js b/lib/v2/agirls/index.js
index c4682d5ff..532728fef 100644
--- a/lib/v2/agirls/index.js
+++ b/lib/v2/agirls/index.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { baseUrl, parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
const link = `${baseUrl}/posts${category ? `/${category}` : ''}`;
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.ag-post-item__link')
.toArray()
@@ -21,11 +21,11 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseArticle(item))));
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text().trim(),
link,
description: $('head meta[name=description]').attr('content'),
item: items,
language: $('html').attr('lang'),
- };
+ });
};
diff --git a/lib/v2/agirls/topic-list.js b/lib/v2/agirls/topic-list.js
index 91fd47be5..22262a6dc 100644
--- a/lib/v2/agirls/topic-list.js
+++ b/lib/v2/agirls/topic-list.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { baseUrl } = require('./utils');
module.exports = async (ctx) => {
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const response = await got(`${baseUrl}/${category}`);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('.ag-topic')
.toArray()
@@ -21,11 +21,11 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text().trim(),
link,
description: $('head meta[name=description]').attr('content'),
item: items,
language: $('html').attr('lang'),
- };
+ });
};
diff --git a/lib/v2/agirls/topic.js b/lib/v2/agirls/topic.js
index 41861820e..97d0357b1 100644
--- a/lib/v2/agirls/topic.js
+++ b/lib/v2/agirls/topic.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { baseUrl, parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
const link = `${baseUrl}/topic/${topic}`;
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const ldJson = JSON.parse($('script[type="application/ld+json"]').text());
const list = $('.ag-post-item__link')
.toArray()
@@ -21,11 +21,11 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseArticle(item))));
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text().trim(),
link,
description: ldJson['@graph'][0].description,
item: items,
language: $('html').attr('lang'),
- };
+ });
};
diff --git a/lib/v2/agirls/utils.js b/lib/v2/agirls/utils.js
index 73cd51410..fe9865a6f 100644
--- a/lib/v2/agirls/utils.js
+++ b/lib/v2/agirls/utils.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://agirls.aotter.net';
const parseArticle = async (item) => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.category = [
...new Set(
diff --git a/lib/v2/agora0/index.js b/lib/v2/agora0/index.js
index afaf4f088..52f7ea1ec 100644
--- a/lib/v2/agora0/index.js
+++ b/lib/v2/agora0/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'initium';
+ const category = ctx.req.param('category') ?? 'initium';
const rootUrl = 'https://agora0.gitlab.io';
const currentUrl = `${rootUrl}/blog/${category}`;
@@ -13,10 +13,10 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.card span:not(.comments) a')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50)
.toArray()
.map((item) => {
item = $(item);
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.author = content('meta[name="author"]').attr('content');
item.pubDate = parseDate(content('meta[property="article:published_time"]').attr('content'));
@@ -46,9 +46,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/agora0/pen0.js b/lib/v2/agora0/pen0.js
index da5312e44..f7a8f3991 100644
--- a/lib/v2/agora0/pen0.js
+++ b/lib/v2/agora0/pen0.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'https://agorahub.github.io';
const response = await got(`${baseUrl}/pen0/`);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('div article')
.toArray()
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
$('h1').remove();
item.description = $('article').html();
return item;
@@ -33,11 +33,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
description: $('head meta[name="description"]').attr('content'),
link: response.url,
image: $('link[rel="apple-touch-icon"]').attr('href'),
item: items,
- };
+ });
};
diff --git a/lib/v2/ahjzu/news.js b/lib/v2/ahjzu/news.js
index 3c4999f4e..395199390 100644
--- a/lib/v2/ahjzu/news.js
+++ b/lib/v2/ahjzu/news.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://www.ahjzu.edu.cn';
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('#wp_news_w9')
.find('li')
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
const post = content('.wp_articlecontent').html();
item.description = post;
@@ -48,10 +48,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '安建大-通知公告',
description: '安徽建筑大学-通知公告',
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/aicaijing/index.js b/lib/v2/aicaijing/index.js
index 6319cb44f..960093e76 100644
--- a/lib/v2/aicaijing/index.js
+++ b/lib/v2/aicaijing/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'latest';
- const id = ctx.params.id ?? 14;
+ const category = ctx.req.param('category') ?? 'latest';
+ const id = ctx.req.param('id') ?? 14;
const titles = {
14: '热点 - 最新',
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
const rootUrl = 'https://www.aicaijing.com.cn';
const apiRootUrl = 'https://api.aicaijing.com.cn';
- const apiUrl = `${apiRootUrl}/article/detail/list?size=${ctx.query.limit ?? 50}&page=1${categories[category].url}`;
+ const apiUrl = `${apiRootUrl}/article/detail/list?size=${ctx.req.query('limit') ?? 50}&page=1${categories[category].url}`;
const response = await got({
method: 'get',
@@ -65,9 +65,9 @@ module.exports = async (ctx) => {
}),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `AI 财经社 - ${categories[category].title}`,
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/aiea/index.js b/lib/v2/aiea/index.js
index a807a39ff..ea02104e0 100644
--- a/lib/v2/aiea/index.js
+++ b/lib/v2/aiea/index.js
@@ -2,7 +2,7 @@ const buildData = require('@/utils/common-config');
module.exports = async (ctx) => {
const link = 'http://www.aiea.org/0504';
- const period = ctx.params.period ?? '';
+ const period = ctx.req.param('period') ?? '';
let nth_child = 'n';
switch (period) {
diff --git a/lib/v2/aijishu/index.js b/lib/v2/aijishu/index.js
index 07b4caac0..e2861e0b6 100644
--- a/lib/v2/aijishu/index.js
+++ b/lib/v2/aijishu/index.js
@@ -1,13 +1,13 @@
const utils = require('./utils');
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const { type, name = 'newest' } = ctx.params;
const u = name === 'newest' ? `https://aijishu.com/` : `https://aijishu.com/${type}/${name}`;
const html = await got(u);
- const $ = cheerio.load(html.data);
+ const $ = load(html.data);
const title = $('title').text();
const api_path = $('li[data-js-stream-load-more]').attr('data-api-url');
@@ -18,9 +18,9 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.filter((item) => item?.url?.startsWith('/a/') || item?.object?.url.startsWith('/a/')).map((item) => utils.parseArticle(item, ctx)));
- ctx.state.data = {
+ ctx.set('data', {
title: title.split(' - ').slice(0, 2).join(' - '),
link: u,
item: items,
- };
+ });
};
diff --git a/lib/v2/aijishu/utils.js b/lib/v2/aijishu/utils.js
index d23314bab..14e6c756a 100644
--- a/lib/v2/aijishu/utils.js
+++ b/lib/v2/aijishu/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseRelativeDate, parseDate } = require('@/utils/parse-date');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { parseRelativeDate, parseDate } from '@/utils/parse-date';
+import { load } from 'cheerio';
const parseArticle = (item, ctx) => {
const articleUrl = `https://aijishu.com${item.url || item.object.url}`;
@@ -11,7 +11,7 @@ const parseArticle = (item, ctx) => {
let resp, desc;
try {
resp = await got(articleUrl);
- const $ = cheerio.load(resp.data);
+ const $ = load(resp.data);
desc = $('article.fmt').html();
} catch (error) {
if (error.response.status === 403) {
diff --git a/lib/v2/ainvest/article.js b/lib/v2/ainvest/article.js
index 6d8b6d44b..3f6920c32 100644
--- a/lib/v2/ainvest/article.js
+++ b/lib/v2/ainvest/article.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const { getHeaders, randomString, encryptAES, decryptAES } = require('./utils');
module.exports = async (ctx) => {
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
},
data: encryptAES(
JSON.stringify({
- batch: ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30,
+ batch: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30,
startId: null,
tags: {
in: ['markettrends', 'premarket', 'companyinsights', 'macro'],
@@ -33,10 +33,10 @@ module.exports = async (ctx) => {
category: [item.nickName, ...item.tags.map((tag) => tag.code)],
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'AInvest - Latest Articles',
link: 'https://www.ainvest.com/news',
language: 'en',
item: items,
- };
+ });
};
diff --git a/lib/v2/ainvest/news.js b/lib/v2/ainvest/news.js
index 8dc48b9b2..ae6fafdd6 100644
--- a/lib/v2/ainvest/news.js
+++ b/lib/v2/ainvest/news.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const { getHeaders, randomString, decryptAES } = require('./utils');
module.exports = async (ctx) => {
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
terminal: 'web',
tab: 'all',
page: 1,
- size: ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 50,
+ size: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 50,
lastId: '',
timestamp: Date.now(),
},
@@ -30,10 +30,10 @@ module.exports = async (ctx) => {
comments: item.commentCount,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'AInvest - Latest News',
link: 'https://www.ainvest.com/news',
language: 'en',
item: items,
- };
+ });
};
diff --git a/lib/v2/aip/journal-pupp.js b/lib/v2/aip/journal-pupp.js
index 2b1738231..5c39ccb1b 100644
--- a/lib/v2/aip/journal-pupp.js
+++ b/lib/v2/aip/journal-pupp.js
@@ -1,11 +1,12 @@
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const { puppeteerGet, renderDesc } = require('./utils');
-const config = require('@/config').value;
+import { config } from '@/config';
const { isValidHost } = require('@/utils/valid-host');
+import puppeteer from '@/utils/puppeteer';
module.exports = async (ctx) => {
- const pub = ctx.params.pub;
- const jrn = ctx.params.jrn;
+ const pub = ctx.req.param('pub');
+ const jrn = ctx.req.param('jrn');
const host = `https://pubs.aip.org`;
const jrnlUrl = `${host}/${pub}/${jrn}/issue`;
if (!isValidHost(pub)) {
@@ -13,13 +14,13 @@ module.exports = async (ctx) => {
}
// use Puppeteer due to the obstacle by cloudflare challenge
- const browser = await require('@/utils/puppeteer')();
+ const browser = await puppeteer();
const { jrnlName, list } = await ctx.cache.tryGet(
jrnlUrl,
async () => {
const response = await puppeteerGet(jrnlUrl, browser);
- const $ = cheerio.load(response);
+ const $ = load(response);
const jrnlName = $('.header-journal-title').text();
const list = $('.card')
.toArray()
@@ -49,10 +50,10 @@ module.exports = async (ctx) => {
browser.close();
- ctx.state.data = {
+ ctx.set('data', {
title: jrnlName,
link: jrnlUrl,
item: list,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/aip/journal.js b/lib/v2/aip/journal.js
index 9c32f52cd..73c23528e 100644
--- a/lib/v2/aip/journal.js
+++ b/lib/v2/aip/journal.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { renderDesc } = require('./utils');
module.exports = async (ctx) => {
- const pub = ctx.params.pub;
- const jrn = ctx.params.jrn;
+ const pub = ctx.req.param('pub');
+ const jrn = ctx.req.param('jrn');
const host = `https://pubs.aip.org`;
const jrnlUrl = `${host}/${pub}/${jrn}/issue`;
const { data: response } = await got.get(jrnlUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
const jrnlName = $('meta[property="og:title"]')
.attr('content')
.match(/(?:[^=]*=)?\s*([^>]+)\s*/)[1];
@@ -46,10 +46,10 @@ module.exports = async (ctx) => {
})
.get();
- ctx.state.data = {
+ ctx.set('data', {
title: jrnlName,
link: jrnlUrl,
item: list,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/aip/utils.js b/lib/v2/aip/utils.js
index 988a82683..d5914c56f 100644
--- a/lib/v2/aip/utils.js
+++ b/lib/v2/aip/utils.js
@@ -1,5 +1,5 @@
const path = require('path');
-const { art } = require('@/utils/render');
+import { art } from '@/utils/render';
const puppeteerGet = async (url, browser) => {
const page = await browser.newPage();
diff --git a/lib/v2/airchina/index.js b/lib/v2/airchina/index.js
index 803b82f54..ac5dc0f82 100644
--- a/lib/v2/airchina/index.js
+++ b/lib/v2/airchina/index.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const buildData = require('@/utils/common-config');
const baseUrl = 'https://www.airchina.com.cn';
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
const detailLink = baseUrl + item.link;
item.description = await ctx.cache.tryGet(detailLink, async () => {
const result = await got(detailLink);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
return $('.serviceMsg').html();
});
})
diff --git a/lib/v2/aisixiang/column.js b/lib/v2/aisixiang/column.js
index c7ca71d19..60932744f 100644
--- a/lib/v2/aisixiang/column.js
+++ b/lib/v2/aisixiang/column.js
@@ -1,19 +1,19 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const currentUrl = new URL(`/data/search?column=${id}`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
const title = $('div.article-title a').first().text().replaceAll('[]', '');
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
@@ -41,5 +41,5 @@ module.exports = async (ctx) => {
language: 'zh-cn',
image: new URL('images/logo.jpg', ossUrl).href,
subtitle: title,
- };
+ });
};
diff --git a/lib/v2/aisixiang/thinktank.js b/lib/v2/aisixiang/thinktank.js
index c0aadb275..491226d2a 100644
--- a/lib/v2/aisixiang/thinktank.js
+++ b/lib/v2/aisixiang/thinktank.js
@@ -1,17 +1,17 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
module.exports = async (ctx) => {
const { id, type = '' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const currentUrl = new URL(`thinktank/${id}.html`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
const title = `${$('h2').first().text().trim()}${type}`;
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
@@ -45,5 +45,5 @@ module.exports = async (ctx) => {
language: 'zh-cn',
image: new URL('images/logo_thinktank.jpg', ossUrl).href,
subtitle: title,
- };
+ });
};
diff --git a/lib/v2/aisixiang/toplist.js b/lib/v2/aisixiang/toplist.js
index 1299cebf8..e51fae32f 100644
--- a/lib/v2/aisixiang/toplist.js
+++ b/lib/v2/aisixiang/toplist.js
@@ -1,18 +1,18 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
module.exports = async (ctx) => {
const { id = '1', period = '1' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const currentUrl = new URL(`toplist${id ? `?id=${id}${id === '1' ? `&period=${period}` : ''}` : ''}`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
const title = `${$('a.hl').text() || ''}${$('title').text().split('_')[0]}`;
@@ -32,12 +32,12 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
language: 'zh-cn',
image: new URL('images/logo_toplist.jpg', ossUrl).href,
subtitle: title,
- };
+ });
};
diff --git a/lib/v2/aisixiang/utils.js b/lib/v2/aisixiang/utils.js
index 4dd1404ae..480d6e4c4 100644
--- a/lib/v2/aisixiang/utils.js
+++ b/lib/v2/aisixiang/utils.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const ossUrl = 'https://oss.aisixiang.com';
const rootUrl = 'https://www.aisixiang.com';
@@ -12,7 +12,7 @@ const ProcessFeed = (limit, tryGet, items) =>
tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
const commentMatches = content('h3.comment-header')
.text()
diff --git a/lib/v2/aisixiang/zhuanti.js b/lib/v2/aisixiang/zhuanti.js
index a20945bab..3eb0e8bc5 100644
--- a/lib/v2/aisixiang/zhuanti.js
+++ b/lib/v2/aisixiang/zhuanti.js
@@ -1,19 +1,19 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const currentUrl = new URL(`zhuanti/${id}.html`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
const title = $('div.tips h2').first().text();
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
@@ -41,5 +41,5 @@ module.exports = async (ctx) => {
language: 'zh-cn',
image: new URL('images/logo_zhuanti.jpg', ossUrl).href,
subtitle: title,
- };
+ });
};
diff --git a/lib/v2/ajmide/index.js b/lib/v2/ajmide/index.js
index fe6f1ba16..a126f2943 100644
--- a/lib/v2/ajmide/index.js
+++ b/lib/v2/ajmide/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id;
- const limit = ctx.params.limit ?? 25;
+ const id = ctx.req.param('id');
+ const limit = ctx.req.param('limit') ?? 25;
const playListAPI = `https://a.ajmide.com/v3/getBrandContentList.php?brandId=${id}&c=${limit}&i=0`;
const response = await got.get(playListAPI);
const data = response.data.data.filter((item) => !item.contentType);
@@ -19,11 +19,11 @@ module.exports = async (ctx) => {
enclosure_type: 'audio/x-m4a',
}));
- ctx.state.data = {
+ ctx.set('data', {
title: data[0].brandName,
link: `https://m.ajmide.com/m/brand?id=${id}`,
itunes_author: data[0].author_info.nick,
image: data[0].brandImgPath,
item: items,
- };
+ });
};
diff --git a/lib/v2/aliresearch/information.js b/lib/v2/aliresearch/information.js
index 7d6b5323b..8b097e6c2 100644
--- a/lib/v2/aliresearch/information.js
+++ b/lib/v2/aliresearch/information.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const type = ctx.params.type ?? '新闻';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50;
+ const type = ctx.req.param('type') ?? '新闻';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const rootUrl = 'http://www.aliresearch.com';
const currentUrl = `${rootUrl}/cn/information`;
@@ -49,9 +49,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `阿里研究院 - ${type}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/alistapart/index.js b/lib/v2/alistapart/index.js
index 8be8b9eea..7593674c3 100644
--- a/lib/v2/alistapart/index.js
+++ b/lib/v2/alistapart/index.js
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
const data = await getData(`${baseUrl}${route}`);
const items = await getList(data);
- ctx.state.data = {
+ ctx.set('data', {
title: 'A List Apart',
link: `${baseUrl}/articles`,
item: items,
@@ -15,5 +15,5 @@ module.exports = async (ctx) => {
logo: 'https://i0.wp.com/alistapart.com/wp-content/uploads/2019/03/cropped-icon_navigation-laurel-512.jpg?fit=192,192&ssl=1',
icon: 'https://i0.wp.com/alistapart.com/wp-content/uploads/2019/03/cropped-icon_navigation-laurel-512.jpg?fit=32,32&ssl=1',
language: 'en-us',
- };
+ });
};
diff --git a/lib/v2/alistapart/topic.js b/lib/v2/alistapart/topic.js
index d9db2097c..2f0f82898 100644
--- a/lib/v2/alistapart/topic.js
+++ b/lib/v2/alistapart/topic.js
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const data = await getData(`${baseUrl}${articleRoute}${id}&_embed`);
const items = await getList(data);
- ctx.state.data = {
+ ctx.set('data', {
title: 'A List Apart',
link: `${baseUrl}/blog/topic/${topic}`,
item: items,
@@ -17,5 +17,5 @@ module.exports = async (ctx) => {
logo: 'https://i0.wp.com/alistapart.com/wp-content/uploads/2019/03/cropped-icon_navigation-laurel-512.jpg?fit=192,192&ssl=1',
icon: 'https://i0.wp.com/alistapart.com/wp-content/uploads/2019/03/cropped-icon_navigation-laurel-512.jpg?fit=32,32&ssl=1',
language: 'en-us',
- };
+ });
};
diff --git a/lib/v2/alistapart/utils.js b/lib/v2/alistapart/utils.js
index 5f68f3d68..4ffd89716 100644
--- a/lib/v2/alistapart/utils.js
+++ b/lib/v2/alistapart/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const getData = (url) => got.get(url).json();
diff --git a/lib/v2/aliyun/database-month.js b/lib/v2/aliyun/database-month.js
index a3a176478..1bf00b0f0 100644
--- a/lib/v2/aliyun/database-month.js
+++ b/lib/v2/aliyun/database-month.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const url = 'http://mysql.taobao.org/monthly/';
const response = await got({ method: 'get', url });
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $("ul[class='posts'] > li")
.map((i, e) => {
@@ -25,16 +25,16 @@ module.exports = async (ctx) => {
return ctx.cache.tryGet(link, async () => {
const itemReponse = await got(link);
- const itemElement = cheerio.load(itemReponse.data);
+ const itemElement = load(itemReponse.data);
item.description = itemElement('.content').html();
return item;
});
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: url,
item: result.reverse(),
- };
+ });
};
diff --git a/lib/v2/aliyun/developer/group.js b/lib/v2/aliyun/developer/group.js
index 1027b3056..465f86cdb 100644
--- a/lib/v2/aliyun/developer/group.js
+++ b/lib/v2/aliyun/developer/group.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
const link = `https://developer.aliyun.com/group/${type}`;
// 发起 HTTP GET 请求
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const data = response.data;
// 使用 cheerio 加载返回的 HTML
- const $ = cheerio.load(data);
+ const $ = load(data);
const title = $('div[class="header-information-title"]')
.contents()
.filter(function () {
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
const desc = $('div[class="header-information"]').find('span').last().text().trim();
const list = $('ul[class^="content-tab-list"] > li');
- ctx.state.data = {
+ ctx.set('data', {
title: `阿里云开发者社区-${title}`,
link,
description: desc,
@@ -45,5 +45,5 @@ module.exports = async (ctx) => {
};
})
.get(),
- };
+ });
};
diff --git a/lib/v2/aliyun/notice.js b/lib/v2/aliyun/notice.js
index a3ece66d7..4bc55f695 100644
--- a/lib/v2/aliyun/notice.js
+++ b/lib/v2/aliyun/notice.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const typeMap = {
0: '9004748',
@@ -16,10 +16,10 @@ const typeMap = {
* @param ctx {import('koa').Context}
*/
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
const url = `https://help.aliyun.com/noticelist/${typeMap[type] || typeMap[0]}.html`;
const response = await got({ method: 'get', url });
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('ul > li.notice-li')
.map((i, e) => {
const element = $(e);
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const itemReponse = await got(item.link);
- const itemElement = cheerio.load(itemReponse.data);
+ const itemElement = load(itemReponse.data);
item.description = itemElement('#se-knowledge').html();
return item;
@@ -48,9 +48,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text().trim(),
link: url,
item: result,
- };
+ });
};
diff --git a/lib/v2/aljazeera/index.js b/lib/v2/aljazeera/index.js
index d2025714a..f1e00776e 100644
--- a/lib/v2/aljazeera/index.js
+++ b/lib/v2/aljazeera/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const languages = {
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = isRSS
? response.data.match(new RegExp('' + rootUrl + '/(.*?)', 'g')).map((item) => ({
@@ -54,14 +54,14 @@ module.exports = async (ctx) => {
});
items = await Promise.all(
- items.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50).map((item) =>
+ items.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50).map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.more-on').parent().remove();
content('.responsive-image img').removeAttr('srcset');
@@ -79,9 +79,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').first().text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/ally/rail.js b/lib/v2/ally/rail.js
index b22a1c4f9..243bfcd9e 100644
--- a/lib/v2/ally/rail.js
+++ b/lib/v2/ally/rail.js
@@ -1,7 +1,7 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
// http://rail.ally.net.cn/sitemap.html
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
const pageUrl = category ? (topic ? `${rootUrl}/html/${category}/${topic}/` : `${rootUrl}/html/${category}/`) : rootUrl;
const response = await got.get(pageUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let title = $('.container .regsiter a') // what a typo...
.get()
.slice(1) // drop "首页"
@@ -51,13 +51,13 @@ module.exports = async (ctx) => {
.filter(Boolean)
.reduce((prev, curr) => (prev.length && prev.at(-1).link === curr.link ? prev : [...prev, curr]), [])
.sort((a, b) => b.pubDate - a.pubDate)
- .slice(0, ctx.query.limit || 20);
+ .slice(0, ctx.req.query('limit') || 20);
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
// fix weird format
let description = '';
const content = $('div.content_all');
@@ -99,10 +99,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `世界轨道交通资讯网 - ${title}`,
link: pageUrl,
item: items,
description: $('head > meta[name="description"]').attr('content'),
- };
+ });
};
diff --git a/lib/v2/alternativeto/platform.js b/lib/v2/alternativeto/platform.js
index fef2e5525..07a1a6bbd 100644
--- a/lib/v2/alternativeto/platform.js
+++ b/lib/v2/alternativeto/platform.js
@@ -1,16 +1,16 @@
const { baseURL, puppeteerGet } = require('./utils');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const name = ctx.params.name;
- const query = new URLSearchParams(ctx.params.routeParams);
+ const name = ctx.req.param('name');
+ const query = new URLSearchParams(ctx.req.param('routeParams'));
const link = `https://alternativeto.net/platform/${name}/?${query.toString()}`;
// use Puppeteer due to the obstacle by cloudflare challenge
const html = await puppeteerGet(link, ctx.cache);
- const $ = cheerio.load(html);
+ const $ = load(html);
- ctx.state.data = {
+ ctx.set('data', {
title: $('.Heading_h1___Cf5Y').text().trim(),
description: $('.intro-text').text().trim(),
link,
@@ -28,5 +28,5 @@ module.exports = async (ctx) => {
description,
};
}),
- };
+ });
};
diff --git a/lib/v2/alternativeto/software.js b/lib/v2/alternativeto/software.js
index a54d54de7..edf4bc067 100644
--- a/lib/v2/alternativeto/software.js
+++ b/lib/v2/alternativeto/software.js
@@ -1,16 +1,16 @@
const { baseURL, puppeteerGet } = require('./utils');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const name = ctx.params.name;
- const query = new URLSearchParams(ctx.params.routeParams);
+ const name = ctx.req.param('name');
+ const query = new URLSearchParams(ctx.req.param('routeParams'));
const link = `https://alternativeto.net/software/${name}/?${query.toString()}`;
// use Puppeteer due to the obstacle by cloudflare challenge
const html = await puppeteerGet(link, ctx.cache);
- const $ = cheerio.load(html);
+ const $ = load(html);
- ctx.state.data = {
+ ctx.set('data', {
title: $('.Heading_h1___Cf5Y').text().trim(),
description: $('.intro-text').text().trim(),
link,
@@ -28,5 +28,5 @@ module.exports = async (ctx) => {
description,
};
}),
- };
+ });
};
diff --git a/lib/v2/alternativeto/utils.js b/lib/v2/alternativeto/utils.js
index 1ecbc0243..0883dfa52 100644
--- a/lib/v2/alternativeto/utils.js
+++ b/lib/v2/alternativeto/utils.js
@@ -1,8 +1,10 @@
+import puppeteer from '@/utils/puppeteer';
+
const baseURL = 'https://alternativeto.net';
const puppeteerGet = (url, cache) =>
cache.tryGet(url, async () => {
- const browser = await require('@/utils/puppeteer')();
+ const browser = puppeteer();
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
diff --git a/lib/v2/amazon/awsblogs.js b/lib/v2/amazon/awsblogs.js
index 5baa0822b..ea3e78a3f 100644
--- a/lib/v2/amazon/awsblogs.js
+++ b/lib/v2/amazon/awsblogs.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const locale = ctx.params.locale ?? 'zh_CN';
+ const locale = ctx.req.param('locale') ?? 'zh_CN';
const response = await got({
url: `https://aws.amazon.com/api/dirs/items/search?item.directoryId=blog-posts&sort_by=item.additionalFields.createdDate&sort_order=desc&size=50&item.locale=${locale}`,
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
const items = response.data.items;
- ctx.state.data = {
+ ctx.set('data', {
title: 'AWS Blog',
link: 'https://aws.amazon.com/blogs/',
description: 'AWS Blog 更新',
@@ -23,5 +23,5 @@ module.exports = async (ctx) => {
link: item.item.additionalFields.link,
author: item.item.additionalFields.contributors,
})),
- };
+ });
};
diff --git a/lib/v2/amazon/kindle-software-updates.js b/lib/v2/amazon/kindle-software-updates.js
index 9793e7d7c..690c3eb4f 100644
--- a/lib/v2/amazon/kindle-software-updates.js
+++ b/lib/v2/amazon/kindle-software-updates.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const host = 'https://www.amazon.com';
module.exports = async (ctx) => {
const url = host + '/gp/help/customer/display.html';
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
});
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('.a-row.cs-help-landing-section.help-display-cond')
.map(function () {
const data = {};
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
return data;
})
.get();
- ctx.state.data = {
+ ctx.set('data', {
title: 'Kindle E-Reader Software Updates',
link: `${url}?nodeId=${nodeIdValue}`,
description: 'Kindle E-Reader Software Updates',
@@ -44,5 +44,5 @@ module.exports = async (ctx) => {
guid: item.title + ' - ' + item.version,
link: item.link,
})),
- };
+ });
};
diff --git a/lib/v2/android/platform-tools-releases.js b/lib/v2/android/platform-tools-releases.js
index bb8ef6fab..806e83ca6 100644
--- a/lib/v2/android/platform-tools-releases.js
+++ b/lib/v2/android/platform-tools-releases.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://developer.android.com';
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
$('.hide-from-toc').remove();
$('.devsite-dialog, .devsite-badge-awarder, .devsite-hats-survey').remove();
@@ -39,9 +39,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/annualreviews/index.js b/lib/v2/annualreviews/index.js
index 82d5eb76a..1660afc75 100644
--- a/lib/v2/annualreviews/index.js
+++ b/lib/v2/annualreviews/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const rootUrl = 'https://www.annualreviews.org';
const apiRootUrl = `https://api.crossref.org`;
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
url: feedUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('entry')
.toArray()
@@ -56,7 +56,7 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title')
.first()
.text()
@@ -64,5 +64,5 @@ module.exports = async (ctx) => {
description: $('subtitle').first().text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/anquanke/category.js b/lib/v2/anquanke/category.js
index be7ec7bdd..8303019fa 100644
--- a/lib/v2/anquanke/category.js
+++ b/lib/v2/anquanke/category.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const api = 'https://api.anquanke.com/data/v1/posts?size=10&page=1&category=';
- const type = ctx.params.category;
- const fulltext = ctx.params.fulltext;
+ const type = ctx.req.param('category');
+ const fulltext = ctx.req.param('fulltext');
const host = 'https://www.anquanke.com';
const res = await got(`${api}${type}`);
const dataArray = res.data.data;
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
fulltext === 'fulltext' || fulltext === 'quanwen'
? await ctx.cache.tryGet(art_url, async () => {
const { data: res } = await got(art_url);
- const content = cheerio.load(res);
+ const content = load(res);
return content('#js-article').html();
})
: item.desc,
@@ -31,9 +31,9 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `安全客-${dataArray[0].category_name}`,
link: `https://www.anquanke.com/${type === 'week' ? 'week-list' : type}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/anquanke/vul.js b/lib/v2/anquanke/vul.js
index 318191041..0f50a7a20 100644
--- a/lib/v2/anquanke/vul.js
+++ b/lib/v2/anquanke/vul.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const url = 'https://www.anquanke.com';
const response = await got(`${url}/vul`);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('table>tbody>tr').get();
const items = list.map((i) => {
@@ -26,9 +26,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: '安全客-漏洞cve报告',
link: 'https://www.anquanke.com/vul',
item: items,
- };
+ });
};
diff --git a/lib/v2/apache/apisix/blog.js b/lib/v2/apache/apisix/blog.js
index 3c2fe24e9..226be9f86 100644
--- a/lib/v2/apache/apisix/blog.js
+++ b/lib/v2/apache/apisix/blog.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
async function getArticles() {
const url = 'https://apisix.apache.org/zh/blog/';
const { data: res } = await got(url);
- const $ = cheerio.load(res);
+ const $ = load(res);
const articles = $('section.sec_gjjg').eq(1).find('article');
return articles.toArray().map((elem) => {
const a = $(elem).find('header > a');
@@ -24,9 +24,9 @@ async function getArticles() {
module.exports = async (ctx) => {
const articles = await getArticles();
- ctx.state.data = {
+ ctx.set('data', {
title: 'Blog | Apache APISIX',
link: 'https://apisix.apache.org/zh/blog/',
item: articles,
- };
+ });
};
diff --git a/lib/v2/apiseven/blog.js b/lib/v2/apiseven/blog.js
index 6abafb56f..ddba10149 100644
--- a/lib/v2/apiseven/blog.js
+++ b/lib/v2/apiseven/blog.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const md = require('markdown-it')({
html: true,
});
@@ -9,7 +9,7 @@ const md = require('markdown-it')({
async function getArticles() {
const url = 'https://www.apiseven.com/blog';
const { data: res } = await got(url);
- const $ = cheerio.load(res);
+ const $ = load(res);
const json = JSON.parse($('#__NEXT_DATA__').text());
return json.props.pageProps.list.map((item) => ({
title: item.title,
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
articles.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: res } = await got(item.link);
- const $ = cheerio.load(res);
+ const $ = load(res);
const json = JSON.parse($('#__NEXT_DATA__').text());
return {
title: item.title,
@@ -38,9 +38,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '博客 | 支流科技',
link: 'https://www.apiseven.com/blog',
item: items,
- };
+ });
};
diff --git a/lib/v2/apkpure/versions.js b/lib/v2/apkpure/versions.js
index f6cbd739f..ef51d10e0 100644
--- a/lib/v2/apkpure/versions.js
+++ b/lib/v2/apkpure/versions.js
@@ -1,13 +1,14 @@
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const logger = require('@/utils/logger');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
+import puppeteer from '@/utils/puppeteer';
module.exports = async (ctx) => {
const { pkg, region = 'en' } = ctx.params;
const baseUrl = 'https://apkpure.com';
const link = `${baseUrl}/${region}/${pkg}/versions`;
- const browser = await require('@/utils/puppeteer')();
+ const browser = puppeteer();
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const r = await page.evaluate(() => document.documentElement.innerHTML);
browser.close();
- const $ = cheerio.load(r);
+ const $ = load(r);
const img = new URL($('.ver-top img').attr('src'));
img.searchParams.delete('w'); // get full resolution icon
@@ -37,12 +38,12 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('.ver-top-h1').text(),
description: $('.ver-top-title p').text(),
image: img.href,
language: region ?? 'en',
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/apnews/topics.js b/lib/v2/apnews/topics.js
index 68e1bd65e..e1727ee39 100644
--- a/lib/v2/apnews/topics.js
+++ b/lib/v2/apnews/topics.js
@@ -1,18 +1,18 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
const HOME_PAGE = 'https://apnews.com';
module.exports = async (ctx) => {
const { topic = 'trending-news' } = ctx.params;
const url = `${HOME_PAGE}/hub/${topic}`;
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = await Promise.all(
$('.PagePromo-content bsp-custom-headline')
.get()
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : Infinity)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : Infinity)
.map((e) => ({
title: $(e).find('span.PagePromoContentIcons-text').text(),
link: $(e).find('a').attr('href'),
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
$('div.Enhancement').remove();
return Object.assign(item, {
pubDate: timezone(new Date($("meta[property='article:published_time']").attr('content')), 0),
@@ -34,11 +34,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
description: $("meta[property='og:description']").text(),
link: url,
item: items,
language: $('html').attr('lang'),
- };
+ });
};
diff --git a/lib/v2/app-center/release.js b/lib/v2/app-center/release.js
index 7901b1937..5daeed79a 100644
--- a/lib/v2/app-center/release.js
+++ b/lib/v2/app-center/release.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const MarkdownIt = require('markdown-it');
module.exports = async (ctx) => {
- const user = ctx.params.user;
- const app = ctx.params.app;
- const distribution_group = ctx.params.distribution_group;
+ const user = ctx.req.param('user');
+ const app = ctx.req.param('app');
+ const distribution_group = ctx.req.param('distribution_group');
const baseUrl = 'https://install.appcenter.ms/api/v0.1/apps';
const apiUrl = `${baseUrl}/${user}/${app}/distribution_groups/${distribution_group}`;
@@ -110,11 +110,11 @@ module.exports = async (ctx) => {
const icon = items && items[0]._feed_icon; // if it is an empty feed, would not raise an error here
const title = items && items[0]._feed_title;
- ctx.state.data = {
+ ctx.set('data', {
title,
link,
description: title,
image: icon,
item: items,
- };
+ });
};
diff --git a/lib/v2/apple/apps.js b/lib/v2/apple/apps.js
index d6b762dca..7d8722a34 100644
--- a/lib/v2/apple/apps.js
+++ b/lib/v2/apple/apps.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const platformIds = {
osx: 'macOS',
@@ -26,14 +26,14 @@ module.exports = async (ctx) => {
}
platform = undefined;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 100;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 100;
const rootUrl = 'https://apps.apple.com';
const currentUrl = new URL(`${country}/app/${id}`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
const subtitle = $('h2.whats-new__headline').text() || "What's New";
@@ -87,7 +87,7 @@ module.exports = async (ctx) => {
const icon = new URL('favicon.ico', rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title,
link: currentUrl,
@@ -99,9 +99,9 @@ module.exports = async (ctx) => {
subtitle: appName,
author: artistName,
allowEmpty: true,
- };
+ });
- ctx.state.json = {
+ ctx.set('json', {
appData,
- };
+ });
};
diff --git a/lib/v2/apple/exchange-repair.js b/lib/v2/apple/exchange-repair.js
index 2a04b46d5..ee34d0402 100644
--- a/lib/v2/apple/exchange-repair.js
+++ b/lib/v2/apple/exchange-repair.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const host = 'https://support.apple.com/';
module.exports = async (ctx) => {
- const country = ctx.params.country ?? '';
+ const country = ctx.req.param('country') ?? '';
const link = new URL(`${country}/service-programs`, host).href;
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('section.as-container-column')
.toArray()
.map((item) => {
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $$ = cheerio.load(response.data);
+ const $$ = load(response.data);
// delete input and dropdown elements
$$('div.as-sn-lookup-wrapper').remove();
@@ -39,9 +39,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `Apple - ${$('h1.as-center').text()}`,
link,
item: out,
- };
+ });
};
diff --git a/lib/v2/appleinsider/index.js b/lib/v2/appleinsider/index.js
index fef6066d1..8e9091c84 100644
--- a/lib/v2/appleinsider/index.js
+++ b/lib/v2/appleinsider/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const category = ctx.params.category ?? '';
+ const category = ctx.req.param('category') ?? '';
const rootUrl = 'https://appleinsider.com';
const currentUrl = `${rootUrl}${category ? `/${category}` : ''}`;
@@ -13,10 +13,10 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $(`${category === '' ? '#news-river ' : ''}.river`)
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 30)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 30)
.toArray()
.map((item) => {
item = $(item).find('a').first();
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('#article-social').next().remove();
content('#article-hero, #article-social').remove();
@@ -51,9 +51,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/appstore/in-app-purchase.js b/lib/v2/appstore/in-app-purchase.js
index 1fdb885a8..a74a9d218 100644
--- a/lib/v2/appstore/in-app-purchase.js
+++ b/lib/v2/appstore/in-app-purchase.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const url = require('url');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const country = ctx.params.country;
- const id = ctx.params.id;
+ const country = ctx.req.param('country');
+ const id = ctx.req.param('id');
const link = `https://apps.apple.com/${country}/app/${id}`;
const target = url.resolve(link, '?mt=8#see-all/in-app-purchases');
const res = await got.get(target);
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const lang = $('html').attr('lang');
const apiResponse = (
@@ -50,9 +50,9 @@ module.exports = async (ctx) => {
});
}
- ctx.state.data = {
+ ctx.set('data', {
title,
link,
item,
- };
+ });
};
diff --git a/lib/v2/appstore/price.js b/lib/v2/appstore/price.js
index db3bc667c..ec490cc37 100644
--- a/lib/v2/appstore/price.js
+++ b/lib/v2/appstore/price.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const currency = require('currency-symbol-map');
module.exports = async (ctx) => {
- const country = ctx.params.country;
- const type = ctx.params.type.toLowerCase() === 'mac' ? 'macapps' : 'apps';
- const id = ctx.params.id.replace('id', '');
+ const country = ctx.req.param('country');
+ const type = ctx.req.param('type').toLowerCase() === 'mac' ? 'macapps' : 'apps';
+ const id = ctx.req.param('id').replace('id', '');
const url = `https://buster.cheapcharts.de/v1/DetailData.php?&store=itunes&country=${country}&itemType=${type}&idInStore=${id}`;
@@ -17,10 +17,10 @@ module.exports = async (ctx) => {
if (!res.data.results) {
const unsupported = '当前 app 未被收录. Price monitor is not available for this app.';
- ctx.state.data = {
+ ctx.set('data', {
title: unsupported,
item: [{ title: unsupported }],
- };
+ });
return;
}
@@ -44,10 +44,10 @@ module.exports = async (ctx) => {
};
item.push(single);
}
- ctx.state.data = {
+ ctx.set('data', {
title,
link,
item,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/appstore/xianmian.js b/lib/v2/appstore/xianmian.js
index a34adc6bd..daa5683a2 100644
--- a/lib/v2/appstore/xianmian.js
+++ b/lib/v2/appstore/xianmian.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const {
data: { objects: data },
} = await got.get('https://app.so/api/v5/appso/discount/?platform=web&limit=10');
- ctx.state.data = {
+ ctx.set('data', {
title: '每日精品限免 / 促销应用',
link: 'http://app.so/xianmian/',
description: '鲜面连线 by AppSo:每日精品限免 / 促销应用',
@@ -24,5 +24,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.updated_at * 1000),
link: item.app.download_link[0].link,
})),
- };
+ });
};
diff --git a/lib/v2/aqara/community.js b/lib/v2/aqara/community.js
index f15358081..79bc3ddce 100644
--- a/lib/v2/aqara/community.js
+++ b/lib/v2/aqara/community.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
- const keyword = ctx.params.keyword ?? '';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 100;
+ const id = ctx.req.param('id') ?? '';
+ const keyword = ctx.req.param('keyword') ?? '';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100;
const rootUrl = 'https://community.aqara.com';
const apiUrl = `${rootUrl}/api/v2/feeds?limit=${limit}&platedetail_id=${id}&keyword=${keyword}&all=1`;
@@ -23,10 +23,10 @@ module.exports = async (ctx) => {
author: item.user.nickname,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'Aqara社区',
link: currentUrl,
item: items,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/aqara/news.js b/lib/v2/aqara/news.js
index bdf86be19..9d521cc47 100644
--- a/lib/v2/aqara/news.js
+++ b/lib/v2/aqara/news.js
@@ -1,16 +1,16 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 35;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 35;
const rootUrl = 'https://www.aqara.cn';
const currentUrl = new URL('news', rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
let items = response
.match(/(parm\.newsTitle[\S\s]*?arr\.push\(parm\))/g)
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
item.title = content('h4.fnt_56').last().text();
item.description = content('div.news_body').html();
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
const icon = $('link[rel="shortcut icon"]').prop('href').split('?')[0];
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: $('title').text(),
link: currentUrl,
@@ -49,5 +49,5 @@ module.exports = async (ctx) => {
icon,
logo: icon,
author: $('meta[name="author"]').prop('content'),
- };
+ });
};
diff --git a/lib/v2/aqara/post.js b/lib/v2/aqara/post.js
index bbddc091b..f5f0f981e 100644
--- a/lib/v2/aqara/post.js
+++ b/lib/v2/aqara/post.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 50;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 50;
const rootUrl = 'https://aqara.com';
const apiSlug = 'wp-json/wp/v2';
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
const items = response.slice(0, limit).map((item) => {
const terminologies = item._embedded['wp:term'];
- const content = cheerio.load(item.content?.rendered ?? item.content);
+ const content = load(item.content?.rendered ?? item.content);
// To handle lazy-loaded images.
@@ -72,12 +72,12 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- const $ = cheerio.load(currentResponse);
+ const $ = load(currentResponse);
const icon = $('link[rel="apple-touch-icon"]').first().prop('href');
const title = $('meta[property="og:site_name"]').prop('content') ?? 'Aqara';
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `${title}${filterName ? ` - ${filterName}` : ''}`,
link: currentUrl,
@@ -88,5 +88,5 @@ module.exports = async (ctx) => {
logo: icon,
subtitle: $('meta[property="og:type"]').prop('content'),
author: title,
- };
+ });
};
diff --git a/lib/v2/arcteryx/new-arrivals.js b/lib/v2/arcteryx/new-arrivals.js
index a2bd01ca5..00ded0825 100644
--- a/lib/v2/arcteryx/new-arrivals.js
+++ b/lib/v2/arcteryx/new-arrivals.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
const { generateRssData } = require('./utils');
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
});
const items = response.data.universes.universe[1]['items-section'].items.item.map((item, index, arr) => generateRssData(item, index, arr, country));
- ctx.state.data = {
+ ctx.set('data', {
title: `Arcteryx - New Arrivals(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
link: pageUrl,
description: `Arcteryx - New Arrivals(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
@@ -31,5 +31,5 @@ module.exports = async (ctx) => {
item,
}),
})),
- };
+ });
};
diff --git a/lib/v2/arcteryx/outlet.js b/lib/v2/arcteryx/outlet.js
index 213b249ba..6d59db549 100644
--- a/lib/v2/arcteryx/outlet.js
+++ b/lib/v2/arcteryx/outlet.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
const { generateRssData } = require('./utils');
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
});
const items = response.data.universes.universe[1]['items-section'].items.item.map((item, index, arr) => generateRssData(item, index, arr, country));
- ctx.state.data = {
+ ctx.set('data', {
title: `Arcteryx - Outlet(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
link: pageUrl,
description: `Arcteryx - Outlet(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
@@ -33,5 +33,5 @@ module.exports = async (ctx) => {
item,
}),
})),
- };
+ });
};
diff --git a/lib/v2/arcteryx/regear-new-arrivals.js b/lib/v2/arcteryx/regear-new-arrivals.js
index 4c945e649..71c3d5f62 100644
--- a/lib/v2/arcteryx/regear-new-arrivals.js
+++ b/lib/v2/arcteryx/regear-new-arrivals.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
const host = 'https://www.regear.arcteryx.com';
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
});
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const contents = $('script:contains("window.__PRELOADED_STATE__")').text();
const regex = /{.*}/;
let items = JSON.parse(contents.match(regex)[0]).shop.items;
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
return data;
});
- ctx.state.data = {
+ ctx.set('data', {
title: 'Arcteryx - Regear - New Arrivals',
link: url,
description: 'Arcteryx - Regear - New Arrivals',
@@ -45,5 +45,5 @@ module.exports = async (ctx) => {
link: item.link,
description: item.description,
})),
- };
+ });
};
diff --git a/lib/v2/arknights/announce.js b/lib/v2/arknights/announce.js
index b43c87608..edb95a6ff 100644
--- a/lib/v2/arknights/announce.js
+++ b/lib/v2/arknights/announce.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { platform = 'Android', group = 'ALL' } = ctx.params;
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
url: item.webUrl,
});
- const $ = cheerio.load(data);
+ const $ = load(data);
let description =
// 一般来讲是有字的
$('.content').html() ??
@@ -47,9 +47,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `《明日方舟》${group === 'SYSTEM' ? '系统' : group === 'ACTIVITY' ? '活动' : '全部'}公告`,
link: 'https://ak.hypergryph.com/',
item: announceList,
- };
+ });
};
diff --git a/lib/v2/arknights/japan.js b/lib/v2/arknights/japan.js
index d906dab61..3adf9a8a7 100644
--- a/lib/v2/arknights/japan.js
+++ b/lib/v2/arknights/japan.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const response = await got({
@@ -15,11 +15,11 @@ module.exports = async (ctx) => {
link: `https://www.arknights.jp/news/${item.id}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'アークナイツ',
link: 'https://www.arknights.jp/news',
description: 'アークナイツ ニュース',
language: 'ja',
item: newsList,
- };
+ });
};
diff --git a/lib/v2/arknights/news.js b/lib/v2/arknights/news.js
index 0dc3635de..a603783eb 100644
--- a/lib/v2/arknights/news.js
+++ b/lib/v2/arknights/news.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const response = await got({
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
let newslist = response.data;
- const $ = cheerio.load(newslist);
+ const $ = load(newslist);
newslist = $('.articleItem > .articleItemLink');
newslist = await Promise.all(
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const link = `https://ak.hypergryph.com${item.attr('href')}`;
const description = await ctx.cache.tryGet(link, async () => {
const result = await got(link);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
return $('.article-content').html();
});
return {
@@ -34,9 +34,9 @@ module.exports = async (ctx) => {
.get()
);
- ctx.state.data = {
+ ctx.set('data', {
title: '《明日方舟》游戏公告与新闻',
link: 'https://ak.hypergryph.com/news.html',
item: newslist,
- };
+ });
};
diff --git a/lib/v2/artstation/user.js b/lib/v2/artstation/user.js
index 7adb8541c..c2327d9c0 100644
--- a/lib/v2/artstation/user.js
+++ b/lib/v2/artstation/user.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const path = require('path');
-const { art } = require('@/utils/render');
-const config = require('@/config').value;
+import { art } from '@/utils/render';
+import { config } from '@/config';
module.exports = async (ctx) => {
const { handle } = ctx.params;
@@ -86,7 +86,7 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${userData.full_name} - ArtStation`,
description: userData.headline,
link: userData.permalink,
@@ -94,5 +94,5 @@ module.exports = async (ctx) => {
icon: userData.large_avatar_url,
image: userData.default_cover_url,
item: items,
- };
+ });
};
diff --git a/lib/v2/asiantolick/index.js b/lib/v2/asiantolick/index.js
index 181be4ba8..6bac2adc9 100644
--- a/lib/v2/asiantolick/index.js
+++ b/lib/v2/asiantolick/index.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
const { category } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 24;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 24;
const rootUrl = 'https://asiantolick.com';
const apiUrl = new URL('ajax/buscar_posts.php', rootUrl).href;
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
searchParams,
});
- let $ = cheerio.load(response);
+ let $ = load(response);
let items = $('a.miniatura')
.slice(0, limit)
@@ -64,7 +64,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
item.title = content('h1').first().text();
item.description = art(path.join(__dirname, 'templates/description.art'), {
@@ -93,12 +93,12 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- $ = cheerio.load(currentResponse);
+ $ = load(currentResponse);
const title = $('title').text().split(/-/)[0].trim();
const icon = $('link[rel="icon"]').first().prop('href');
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: title === 'Asian To Lick' ? title : `Asian To Lick - ${title}`,
link: currentUrl,
@@ -109,5 +109,5 @@ module.exports = async (ctx) => {
logo: icon,
subtitle: title,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/asus/bios.js b/lib/v2/asus/bios.js
index 2dc074e12..6297cdba5 100644
--- a/lib/v2/asus/bios.js
+++ b/lib/v2/asus/bios.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const getProductID = async (model) => {
@@ -14,7 +14,7 @@ const getProductID = async (model) => {
};
module.exports = async (ctx) => {
- const model = ctx.params.model;
+ const model = ctx.req.param('model');
const { productID, url } = await getProductID(model);
const biosAPI = `https://www.asus.com.cn/support/api/product.asmx/GetPDBIOS?website=cn&model=${model}&pdid=${productID}&sitelang=cn`;
@@ -31,9 +31,9 @@ module.exports = async (ctx) => {
link: url,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${model} BIOS`,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/asus/gpu-tweak.js b/lib/v2/asus/gpu-tweak.js
index 9bd4e277d..a2568f8c7 100644
--- a/lib/v2/asus/gpu-tweak.js
+++ b/lib/v2/asus/gpu-tweak.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const pageUrl = 'https://www.asus.com/campaign/GPU-Tweak-III/tw/index.php';
module.exports = async (ctx) => {
const response = await got(pageUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('section div.inner div.item')
.toArray()
@@ -20,12 +20,12 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
description: $('meta[name=description]').attr('content'),
image: new URL($('head link[rel="shortcut icon"]').attr('href'), pageUrl).href,
link: pageUrl,
item: items,
language: $('html').attr('lang'),
- };
+ });
};
diff --git a/lib/v2/atcoder/contest.js b/lib/v2/atcoder/contest.js
index f65cd3107..a52fe5b11 100644
--- a/lib/v2/atcoder/contest.js
+++ b/lib/v2/atcoder/contest.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const status = ['action', 'upcoming', 'recent'];
- const language = ctx.params.language ?? 'en';
+ const language = ctx.req.param('language') ?? 'en';
- let rated = ctx.params.rated ?? '0';
- const category = ctx.params.category ?? '0';
- const keyword = ctx.params.keyword ?? '';
+ let rated = ctx.req.param('rated') ?? '0';
+ const category = ctx.req.param('category') ?? '0';
+ const keyword = ctx.req.param('keyword') ?? '';
rated = rated === 'active' ? 'action' : rated;
const isStatus = status.includes(rated);
@@ -22,11 +22,11 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $(isStatus ? `#contest-table-${rated}` : '.row')
.find('tr')
- .slice(1, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 20)
+ .slice(1, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20)
.toArray()
.map((item) => {
item = $(item).find('td a').eq(1);
@@ -45,7 +45,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content(`.lang-${language}`).html();
item.pubDate = parseDate(content('.fixtime-full').first().text());
@@ -55,10 +55,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: String(isStatus ? `${$(`#contest-table-${rated} h3`).text()} - AtCoder` : $('title').text()),
link: currentUrl,
item: items,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/atcoder/post.js b/lib/v2/atcoder/post.js
index db6732d50..615046bbe 100644
--- a/lib/v2/atcoder/post.js
+++ b/lib/v2/atcoder/post.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const language = ctx.params.language ?? 'en';
- const keyword = ctx.params.keyword ?? '';
+ const language = ctx.req.param('language') ?? 'en';
+ const keyword = ctx.req.param('keyword') ?? '';
const rootUrl = 'https://atcoder.jp';
const currentUrl = `${rootUrl}/posts?lang=${language}${keyword ? `&keyword=${keyword}` : ''}`;
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('.panel')
.toArray()
@@ -30,9 +30,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${keyword ? `[${keyword}] - ` : ''}${$('title').text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/auto-stats/index.js b/lib/v2/auto-stats/index.js
index a1f15953d..c81177940 100644
--- a/lib/v2/auto-stats/index.js
+++ b/lib/v2/auto-stats/index.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { category = 'xxkd' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const rootUrl = 'http://www.auto-stats.org.cn';
const currentUrl = new URL(`${category}.asp`, rootUrl).href;
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response, 'gbk'));
+ const $ = load(iconv.decode(response, 'gbk'));
let items = $('a.dnews font')
.slice(0, limit)
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse, 'gbk'));
+ const content = load(iconv.decode(detailResponse, 'gbk'));
item.description = content('table tbody tr td.dd').last().html();
@@ -52,7 +52,7 @@ module.exports = async (ctx) => {
const subtitle = $('title').text().split(/——/).pop();
const image = new URL('images/logo.jpg', rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: $('title').text(),
link: currentUrl,
@@ -61,5 +61,5 @@ module.exports = async (ctx) => {
image,
subtitle,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/baai/comments.js b/lib/v2/baai/comments.js
index f6ffa6048..5fb17c70c 100644
--- a/lib/v2/baai/comments.js
+++ b/lib/v2/baai/comments.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const { baseUrl, apiHost } = require('./utils');
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
Array.from(
{
// first 2 pages
- length: (ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 12) / 6,
+ length: (ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 12) / 6,
},
(_, v) => `${apiHost}/api/v1/commentsall?page=${v + 1}`
).map((url) => got.post(url))
@@ -26,9 +26,9 @@ module.exports = async (ctx) => {
guid: `baai:hub:comments:${item.id}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: '评论 - 智源社区',
link: `${baseUrl}/comments`,
item: items,
- };
+ });
};
diff --git a/lib/v2/baai/events.js b/lib/v2/baai/events.js
index feb7c30d6..a9d44cc6b 100644
--- a/lib/v2/baai/events.js
+++ b/lib/v2/baai/events.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const { baseUrl, apiHost, parseEventDetail, parseItem } = require('./utils');
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
Array.from(
{
// first 2 pages
- length: (ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 16) / 8,
+ length: (ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 16) / 8,
},
(_, v) => `${apiHost}/api/v1/events?page=${v + 1}`
).map((url) => got.post(url))
@@ -24,9 +24,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '活动 - 智源社区',
link: `${baseUrl}/events`,
item: items,
- };
+ });
};
diff --git a/lib/v2/baai/hub.js b/lib/v2/baai/hub.js
index 96f52ed4b..53f8bd079 100644
--- a/lib/v2/baai/hub.js
+++ b/lib/v2/baai/hub.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { baseUrl, apiHost, parseEventDetail, parseItem } = require('./utils');
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
Array.from(
{
// first 3 pages
- length: (ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 18) / 6,
+ length: (ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 18) / 6,
},
(_, v) => `${apiHost}/api/v1/story/list?page=${v + 1}&sort=${sort}${tagId ? `&tag_id=${tagId}` : ''}${range ? `&time_range=${range}` : ''}`
).map((url) => got.post(url))
@@ -41,7 +41,7 @@ module.exports = async (ctx) => {
item.description = await parseEventDetail(item);
} else {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = item.is_event ? $('div.box2').html() : $('.post-content').html();
}
return item;
@@ -49,11 +49,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${title ? `${title} - ` : ''}${description ? `${description} - ` : ''}智源社区`,
description: brief,
link: `${baseUrl}/?${tagId ? `tag_id=${tagId}&` : ''}sort=${sort}${range ? `&time_range=${range}` : ''}`,
image: iconUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/baai/utils.js b/lib/v2/baai/utils.js
index f54d94a93..64af92943 100644
--- a/lib/v2/baai/utils.js
+++ b/lib/v2/baai/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const baseUrl = 'https://hub.baai.ac.cn';
const eventUrl = 'https://event.baai.ac.cn';
diff --git a/lib/v2/backlinko/blog.js b/lib/v2/backlinko/blog.js
index 666152552..55046ccc1 100644
--- a/lib/v2/backlinko/blog.js
+++ b/lib/v2/backlinko/blog.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'https://backlinko.com';
const { data: response, url: link } = await got(`${baseUrl}/blog`);
- const $ = cheerio.load(response);
+ const $ = load(response);
const nextData = JSON.parse($('#__NEXT_DATA__').text());
const {
buildId,
@@ -34,11 +34,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: pageProps.page.seo.title,
description: pageProps.page.seo.metaDesc,
link,
language: 'en',
item: items,
- };
+ });
};
diff --git a/lib/v2/bad/index.js b/lib/v2/bad/index.js
index 80668781e..a9b0ab4dd 100644
--- a/lib/v2/bad/index.js
+++ b/lib/v2/bad/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://bad.news';
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
$('.option, .pagination').remove();
@@ -50,9 +50,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `Bad.news - ${$('.active').text()}${$('.selected').text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/baidu/gushitong/index.js b/lib/v2/baidu/gushitong/index.js
index 2ea358a75..170b6c05e 100644
--- a/lib/v2/baidu/gushitong/index.js
+++ b/lib/v2/baidu/gushitong/index.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
const STATUS_MAP = {
@@ -18,11 +18,11 @@ module.exports = async (ctx) => {
}),
link: `https://gushitong.baidu.com/index/${e.market}-${e.code}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: '百度股市通',
description:
'百度股市通,汇聚全球金融市场的股票、基金、外汇、期货等实时行情,7*24小时覆盖专业财经资讯,提供客观、准确、及时、全面的沪深港美上市公司股价、财务、股东、分红等信息,让用户在复杂的金融市场,更简单的获取投资信息。',
link: 'https://gushitong.baidu.com/',
item,
- };
+ });
};
diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js
index 6c8def76a..45ad45e44 100644
--- a/lib/v2/baidu/search.js
+++ b/lib/v2/baidu/search.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images });
-const config = require('@/config').value;
+import { config } from '@/config';
module.exports = async (ctx) => {
const { keyword } = ctx.params;
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
async () => {
const response = (await got(url)).data;
const visitedLinks = new Set();
- const $ = cheerio.load(response);
+ const $ = load(response);
const contentLeft = $('#content_left');
const containers = contentLeft.find('.c-container');
return containers
@@ -45,10 +45,10 @@ module.exports = async (ctx) => {
false
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${keyword} - 百度搜索`,
description: `${keyword} - 百度搜索`,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/baidu/tieba/forum.js b/lib/v2/baidu/tieba/forum.js
index 33a479bfc..c06d90455 100644
--- a/lib/v2/baidu/tieba/forum.js
+++ b/lib/v2/baidu/tieba/forum.js
@@ -1,8 +1,8 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -21,12 +21,11 @@ module.exports = async (ctx) => {
searchParams: params,
});
- const threadListHTML = cheerio
- .load(data)('code[id="pagelet_html_frs-list/pagelet/thread_list"]')
+ const threadListHTML = load(data)('code[id="pagelet_html_frs-list/pagelet/thread_list"]')
.contents()
.filter((e) => e.nodeType === '8');
- const $ = cheerio.load(threadListHTML.prevObject[0].data);
+ const $ = load(threadListHTML.prevObject[0].data);
const list = $('#thread_list > .j_thread_list[data-field]')
.toArray()
.map((element) => {
@@ -56,10 +55,10 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${kw}吧`,
- description: cheerio.load(data)('meta[name="description"]').attr('content'),
+ description: load(data)('meta[name="description"]').attr('content'),
link: `https://tieba.baidu.com/f?kw=${encodeURIComponent(kw)}`,
item: list,
- };
+ });
};
diff --git a/lib/v2/baidu/tieba/post.js b/lib/v2/baidu/tieba/post.js
index 3cf8e5827..88f394e14 100644
--- a/lib/v2/baidu/tieba/post.js
+++ b/lib/v2/baidu/tieba/post.js
@@ -1,8 +1,8 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
+import { art } from '@/utils/render';
const path = require('path');
/**
@@ -20,7 +20,7 @@ async function getPost(id, lz = 0, pn = 7e6) {
Referer: 'https://tieba.baidu.com/',
},
});
- const $ = cheerio.load(data);
+ const $ = load(data);
const max = Number.parseInt($('[max-page]').attr('max-page'));
if (max > pn) {
return getPost(id, max);
@@ -32,12 +32,12 @@ module.exports = async (ctx) => {
const { id } = ctx.params;
const lz = ctx._matchedRoute.includes('lz') ? 1 : 0;
const html = await getPost(id, lz);
- const $ = cheerio.load(html);
+ const $ = load(html);
const title = $('.core_title_txt').attr('title');
// .substr(3);
const list = $('.p_postlist > [data-field]:not(:has(.ad_bottom_view))');
- ctx.state.data = {
+ ctx.set('data', {
title: lz ? `【只看楼主】${title}` : title,
link: `https://tieba.baidu.com/p/${id}?see_lz=${lz}`,
description: `${title}的最新回复`,
@@ -76,5 +76,5 @@ module.exports = async (ctx) => {
};
})
.get(),
- };
+ });
};
diff --git a/lib/v2/baidu/tieba/search.js b/lib/v2/baidu/tieba/search.js
index 6a1bfdb10..68685387e 100644
--- a/lib/v2/baidu/tieba/search.js
+++ b/lib/v2/baidu/tieba/search.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const qw = ctx.params.qw;
- const query = new URLSearchParams(ctx.params.routeParams);
+ const qw = ctx.req.param('qw');
+ const query = new URLSearchParams(ctx.req.param('routeParams'));
query.set('ie', 'utf-8');
query.set('qw', qw);
query.set('rn', query.get('rn') || 20); // Number of returned items
@@ -22,10 +22,10 @@ module.exports = async (ctx) => {
});
const data = iconv.decode(response.data, 'gbk');
- const $ = cheerio.load(data);
+ const $ = load(data);
const resultList = $('div.s_post');
- ctx.state.data = {
+ ctx.set('data', {
title: `${qw} - ${query.get('kw') || '百度贴'}吧搜索`,
link,
item: resultList.toArray().map((element) => {
@@ -59,5 +59,5 @@ module.exports = async (ctx) => {
link,
};
}),
- };
+ });
};
diff --git a/lib/v2/baidu/tieba/user.js b/lib/v2/baidu/tieba/user.js
index 58589ce9f..484f01c06 100644
--- a/lib/v2/baidu/tieba/user.js
+++ b/lib/v2/baidu/tieba/user.js
@@ -1,20 +1,20 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
+ const uid = ctx.req.param('uid');
const response = await got(`https://tieba.baidu.com/home/main?un=${uid}`);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const name = $('span.userinfo_username').text();
const list = $('div.n_right.clearfix');
let imgurl;
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 的贴吧`,
link: `https://tieba.baidu.com/home/main?un=${uid}`,
item:
@@ -29,5 +29,5 @@ module.exports = async (ctx) => {
link: item.find('div.thread_name a').attr('href'),
};
}),
- };
+ });
};
diff --git a/lib/v2/baidu/top.js b/lib/v2/baidu/top.js
index 2dfb374cf..795651131 100644
--- a/lib/v2/baidu/top.js
+++ b/lib/v2/baidu/top.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const link = `https://top.baidu.com/board?tab=${board}`;
const { data: response } = await got(link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const { data } = JSON.parse(
$('#sanRoot')
@@ -25,10 +25,10 @@ module.exports = async (ctx) => {
link: item.rawUrl,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${data.curBoardName} - 百度热搜`,
description: $('meta[name="description"]').attr('content'),
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/bandcamp/live.js b/lib/v2/bandcamp/live.js
index d354cde8b..039df6b9e 100644
--- a/lib/v2/bandcamp/live.js
+++ b/lib/v2/bandcamp/live.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://bandcamp.com';
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
$('.curated-wrapper').remove();
@@ -33,9 +33,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bandcamp/tag.js b/lib/v2/bandcamp/tag.js
index f9cfc88c9..07fc80cf7 100644
--- a/lib/v2/bandcamp/tag.js
+++ b/lib/v2/bandcamp/tag.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const tag = ctx.params.tag;
+ const tag = ctx.req.param('tag');
const rootUrl = 'https://bandcamp.com';
const currentUrl = `${rootUrl}/tag/${tag}?tab=all_releases`;
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = response.data
.match(/tralbum_url":"(.*?)","audio_url/g)
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.title = content('.trackTitle').eq(0).text();
item.author = content('h3 span a').text();
@@ -38,9 +38,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bandcamp/weekly.js b/lib/v2/bandcamp/weekly.js
index 8f1beef14..b72b4446d 100644
--- a/lib/v2/bandcamp/weekly.js
+++ b/lib/v2/bandcamp/weekly.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -21,9 +21,9 @@ module.exports = async (ctx) => {
}),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'Bandcamp Weekly',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bangumi/moe/index.js b/lib/v2/bangumi/moe/index.js
index 9398cfb65..46cadd731 100644
--- a/lib/v2/bangumi/moe/index.js
+++ b/lib/v2/bangumi/moe/index.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const isLatest = ctx.path === '/moe';
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
}
let items =
- response.data.torrents?.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 30).map((item) => ({
+ response.data.torrents?.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 30).map((item) => ({
title: item.title,
link: `${rootUrl}/torrent/${item._id}`,
description: item.introduction,
@@ -83,10 +83,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '萌番组 Bangumi Moe',
link: isLatest || items.length === 0 ? rootUrl : `${rootUrl}/search/${tag_id.join('+')}`,
item: items,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/bangumi/online/online.js b/lib/v2/bangumi/online/online.js
index b6e9871e8..8a81b06a8 100644
--- a/lib/v2/bangumi/online/online.js
+++ b/lib/v2/bangumi/online/online.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { art } from '@/utils/render';
+import { parseDate } from '@/utils/parse-date';
const path = require('path');
module.exports = async (ctx) => {
@@ -20,9 +20,9 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.create_time),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'アニメ新番組',
link: 'https://bangumi.online',
item: items,
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/calendar/_base.js b/lib/v2/bangumi/tv/calendar/_base.js
index 1e99cf616..9f3ac901c 100644
--- a/lib/v2/bangumi/tv/calendar/_base.js
+++ b/lib/v2/bangumi/tv/calendar/_base.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { config } from '@/config';
module.exports = (tryGet) => {
const bgmCalendarUrl = 'https://api.bgm.tv/calendar';
diff --git a/lib/v2/bangumi/tv/calendar/today.js b/lib/v2/bangumi/tv/calendar/today.js
index 36993f1f4..7aa93d6a9 100644
--- a/lib/v2/bangumi/tv/calendar/today.js
+++ b/lib/v2/bangumi/tv/calendar/today.js
@@ -1,5 +1,5 @@
const getData = require('./_base');
-const { art } = require('@/utils/render');
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
bgm.image = images[bgm.bgmId];
}
- ctx.state.data = {
+ ctx.set('data', {
title: 'bangumi 每日放送',
link: 'https://bgm.tv/calendar',
item: todayBgm.map((bgm) => {
@@ -59,5 +59,5 @@ module.exports = async (ctx) => {
content: { html },
};
}),
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/group/reply.js b/lib/v2/bangumi/tv/group/reply.js
index be8a9ac7f..956a6468e 100644
--- a/lib/v2/bangumi/tv/group/reply.js
+++ b/lib/v2/bangumi/tv/group/reply.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
// bangumi.tv未提供获取小组话题的API,因此仍需要通过抓取网页来获取
- const topicID = ctx.params.id;
+ const topicID = ctx.req.param('id');
const link = `https://bgm.tv/group/topic/${topicID}`;
const { data: html } = await got(link);
- const $ = cheerio.load(html);
+ const $ = load(html);
const title = $('#pageHeader h1').text();
const latestReplies = $('.row_reply')
.toArray()
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
link,
};
- ctx.state.data = {
+ ctx.set('data', {
title: `${title}的最新回复`,
link,
item: [
@@ -55,5 +55,5 @@ module.exports = async (ctx) => {
})),
postTopic,
],
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/group/topic.js b/lib/v2/bangumi/tv/group/topic.js
index 1ec21d6b7..ea96abe7e 100644
--- a/lib/v2/bangumi/tv/group/topic.js
+++ b/lib/v2/bangumi/tv/group/topic.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const base_url = 'https://bgm.tv';
module.exports = async (ctx) => {
- const groupID = ctx.params.id;
+ const groupID = ctx.req.param('id');
const link = `${base_url}/group/${groupID}/forum`;
const { data: html } = await got(link);
- const $ = cheerio.load(html);
+ const $ = load(html);
const title = 'Bangumi - ' + $('.SecondaryNavTitle').text();
const items = await Promise.all(
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
const link = new URL($('.subject a', elem).attr('href'), base_url).href;
const fullText = await ctx.cache.tryGet(link, async () => {
const { data: html } = await got(link);
- const $ = cheerio.load(html);
+ const $ = load(html);
return $('.postTopic .topic_content').html();
});
const summary = 'Reply: ' + $('.posts', elem).text();
@@ -31,9 +31,9 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title,
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/other/followrank.js b/lib/v2/bangumi/tv/other/followrank.js
index 7f1245540..b8440f91b 100644
--- a/lib/v2/bangumi/tv/other/followrank.js
+++ b/lib/v2/bangumi/tv/other/followrank.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { config } from '@/config';
module.exports = async (ctx) => {
const url = 'https://bgm.tv/anime';
const response = await got({
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.body);
+ const $ = load(response.body);
const items = [
...$('#columnB > div:nth-child(4) > table > tbody')
@@ -33,10 +33,10 @@ module.exports = async (ctx) => {
})),
];
- ctx.state.data = {
+ ctx.set('data', {
title: 'Bangumi 成员关注动画榜',
link: url,
item: items,
description: `Bangumi 首页-成员关注动画榜`,
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/person/index.js b/lib/v2/bangumi/tv/person/index.js
index 561a6573d..9c918fce9 100644
--- a/lib/v2/bangumi/tv/person/index.js
+++ b/lib/v2/bangumi/tv/person/index.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
// bangumi.tv未提供获取“人物信息”的API,因此仍需要通过抓取网页来获取
- const personID = ctx.params.id;
+ const personID = ctx.req.param('id');
const link = `https://bgm.tv/person/${personID}/works?sort=date`;
const { data: html } = await got(link);
- const $ = cheerio.load(html);
+ const $ = load(html);
const personName = $('.nameSingle a').text();
const works = $('.item')
.toArray()
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${personName}参与的作品`,
link,
item: works.map((c) => {
@@ -34,5 +34,5 @@ module.exports = async (ctx) => {
pubDate: match ? parseDate(match[1], ['YYYY-MM-DD', 'YYYY-M-D']) : null,
};
}),
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/subject/comments.js b/lib/v2/bangumi/tv/subject/comments.js
index 6cb7e5878..dadfe41df 100644
--- a/lib/v2/bangumi/tv/subject/comments.js
+++ b/lib/v2/bangumi/tv/subject/comments.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
module.exports = async (subjectID, minLength) => {
// bangumi.tv未提供获取“吐槽(comments)”的API,因此仍需要通过抓取网页来获取
const link = `https://bgm.tv/subject/${subjectID}/comments`;
const { data: html } = await got(link);
- const $ = cheerio.load(html);
+ const $ = load(html);
const title = $('.nameSingle').find('a').text();
const comments = $('.item')
.toArray()
diff --git a/lib/v2/bangumi/tv/subject/ep.js b/lib/v2/bangumi/tv/subject/ep.js
index 1c11a2077..8a73cbe79 100644
--- a/lib/v2/bangumi/tv/subject/ep.js
+++ b/lib/v2/bangumi/tv/subject/ep.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const { getLocalName } = require('./utils');
diff --git a/lib/v2/bangumi/tv/subject/index.js b/lib/v2/bangumi/tv/subject/index.js
index 53cdab380..1285a01e3 100644
--- a/lib/v2/bangumi/tv/subject/index.js
+++ b/lib/v2/bangumi/tv/subject/index.js
@@ -4,16 +4,16 @@ const getEps = require('./ep.js');
const { queryToBoolean } = require('@/utils/readable-social');
module.exports = async (ctx) => {
- const id = ctx.params.id;
- const type = ctx.params.type || 'ep';
- const showOriginalName = queryToBoolean(ctx.params.showOriginalName);
+ const id = ctx.req.param('id');
+ const type = ctx.req.param('type') || 'ep';
+ const showOriginalName = queryToBoolean(ctx.req.param('showOriginalName'));
let response;
switch (type) {
case 'ep':
response = await getEps(id, showOriginalName);
break;
case 'comments':
- response = await getComments(id, Number(ctx.query.minLength) || 0);
+ response = await getComments(id, Number(ctx.req.query('minLength')) || 0);
break;
case 'blogs':
response = await getFromAPI('blog')(id, showOriginalName);
diff --git a/lib/v2/bangumi/tv/subject/offcial-subject-api.js b/lib/v2/bangumi/tv/subject/offcial-subject-api.js
index 2020e5150..883eddd32 100644
--- a/lib/v2/bangumi/tv/subject/offcial-subject-api.js
+++ b/lib/v2/bangumi/tv/subject/offcial-subject-api.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const { getLocalName } = require('./utils');
module.exports = (type) => {
diff --git a/lib/v2/bangumi/tv/user/blog.js b/lib/v2/bangumi/tv/user/blog.js
index 466eec5ce..b74aad867 100644
--- a/lib/v2/bangumi/tv/user/blog.js
+++ b/lib/v2/bangumi/tv/user/blog.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
- const currentUrl = `https://bgm.tv/user/${ctx.params.id}/blog`;
+ const currentUrl = `https://bgm.tv/user/${ctx.req.param('id')}/blog`;
const response = await got({
method: 'get',
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('#entry_list div.item')
.find('h2.title')
.toArray()
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const res = await got({ method: 'get', url: item.link });
- const content = cheerio.load(res.data);
+ const content = load(res.data);
item.description = content('#entry_content').html();
return item;
@@ -35,9 +35,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bangumi/tv/user/wish.js b/lib/v2/bangumi/tv/user/wish.js
index f89288ded..573f84ace 100644
--- a/lib/v2/bangumi/tv/user/wish.js
+++ b/lib/v2/bangumi/tv/user/wish.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { config } from '@/config';
module.exports = async (ctx) => {
- const userid = ctx.params.id;
+ const userid = ctx.req.param('id');
const url = `https://bgm.tv/anime/list/${userid}/wish`;
const response = await got({
url,
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
'User-Agent': config.trueUA,
},
});
- const $ = cheerio.load(response.body);
+ const $ = load(response.body);
const username = $('.name').find('a').html();
const items = $('#browserItemList')
@@ -29,10 +29,10 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${username}想看的动画`,
link: url,
item: items,
description: `${username}想看的动画列表`,
- };
+ });
};
diff --git a/lib/v2/baozimh/index.js b/lib/v2/baozimh/index.js
index 6e4e2bcec..4d940adcb 100644
--- a/lib/v2/baozimh/index.js
+++ b/lib/v2/baozimh/index.js
@@ -1,16 +1,16 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
const rootUrl = 'https://www.baozimh.com';
module.exports = async (ctx) => {
- const name = ctx.params.name;
+ const name = ctx.req.param('name');
const url = `${rootUrl}/comic/${name}`;
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const comicTitle = $('div > div.pure-u-1-1.pure-u-sm-2-3.pure-u-md-3-4 > div > h1').text();
const list = $('#layout > div.comics-detail > div:nth-child(3) > div > div:nth-child(4) > div')
.toArray()
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const $ = cheerio.load(detailResponse.data);
+ const $ = load(detailResponse.data);
item.description = art(path.join(__dirname, 'templates/desc.art'), {
imgUrlList: $('.comic-contain')
.find('amp-img')
@@ -41,10 +41,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `包子漫画-${comicTitle}`,
description: $('.comics-detail__desc').text(),
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/barronschina/index.js b/lib/v2/barronschina/index.js
index 691355263..68f1459aa 100644
--- a/lib/v2/barronschina/index.js
+++ b/lib/v2/barronschina/index.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '';
+ const id = ctx.req.param('id') ?? '';
const rootUrl = 'http://www.barronschina.com.cn';
const currentUrl = `${rootUrl}/index/${id ? `column/article?columnId=${id}` : 'shortNews'}`;
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = id
? await Promise.all(
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.cont_main').html();
item.pubDate = timezone(parseDate(content('.timeTag').text()), +8);
@@ -62,9 +62,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text().split(',')[0],
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bast/index.js b/lib/v2/bast/index.js
index 6f140c41c..a776769c5 100644
--- a/lib/v2/bast/index.js
+++ b/lib/v2/bast/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const colPath = ctx.path.replace(/^\//, '') || '32942';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const rootUrl = 'https://www.bast.net.cn';
const currentUrl = `${rootUrl}/${isNaN(colPath) ? colPath : `col/col${colPath}`}/`;
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- let $ = cheerio.load(response.data);
+ let $ = load(response.data);
$('.list-title-bif').remove();
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
let selection = $('a[title]');
if (selection.length === 0) {
- $ = cheerio.load($('ul.cont-list div script').first().text());
+ $ = load($('ul.cont-list div script').first().text());
$('.list-title-bif').remove();
@@ -51,7 +51,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.title = content('meta[name="ArticleTitle"]').attr('content');
item.author = content('meta[name="contentSource"]').attr('content');
@@ -66,9 +66,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bbc/index.js b/lib/v2/bbc/index.js
index e0292d035..2f7f4df01 100644
--- a/lib/v2/bbc/index.js
+++ b/lib/v2/bbc/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const utils = require('./utils');
module.exports = async (ctx) => {
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const description = response.request.options.url.pathname.startsWith('/news/av') ? item.content : utils.ProcessFeed($);
@@ -68,11 +68,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title,
link,
image: 'https://www.bbc.com/favicon.ico',
description: title,
item: items,
- };
+ });
};
diff --git a/lib/v2/bbcnewslabs/news.js b/lib/v2/bbcnewslabs/news.js
index 820b1c2e6..ecef0ffbf 100644
--- a/lib/v2/bbcnewslabs/news.js
+++ b/lib/v2/bbcnewslabs/news.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://bbcnewslabs.co.uk';
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
url: `${rootUrl}/news`,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = [...$('a[href^="/news/20"]')]
.map((_, item) => {
@@ -23,9 +23,9 @@ module.exports = async (ctx) => {
})
.get();
- ctx.state.data = {
+ ctx.set('data', {
title: 'News - BBC News Labs',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bdys/index.js b/lib/v2/bdys/index.js
index c2b583134..987ec128b 100644
--- a/lib/v2/bdys/index.js
+++ b/lib/v2/bdys/index.js
@@ -1,25 +1,25 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
+import { art } from '@/utils/render';
const path = require('path');
const asyncPool = require('tiny-async-pool');
-const config = require('@/config').value;
+import { config } from '@/config';
// Visit https://www.bdys.me for the list of domains
const allowDomains = new Set(['52bdys.com', 'bde4.icu', 'bdys01.com']);
module.exports = async (ctx) => {
- const caty = ctx.params.caty || 'all';
- const type = ctx.params.type || 'all';
- const area = ctx.params.area || 'all';
- const year = ctx.params.year || 'all';
- const order = ctx.params.order || '0';
+ const caty = ctx.req.param('caty') || 'all';
+ const type = ctx.req.param('type') || 'all';
+ const area = ctx.req.param('area') || 'all';
+ const year = ctx.req.param('year') || 'all';
+ const order = ctx.req.param('order') || '0';
- const site = ctx.query.domain || 'bdys01.com';
+ const site = ctx.req.query('domain') || 'bdys01.com';
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomains.has(new URL(`https://${site}`).hostname)) {
- ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
+ throw new Error(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
const rootUrl = `https://www.${site}`;
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let jsessionid = '';
@@ -66,7 +66,7 @@ module.exports = async (ctx) => {
url: `${rootUrl}/downloadInfo/list?mid=${item.link.split('/')[4].split('.')[0]}`,
headers,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('svg').remove();
const torrents = content('.download-list .list-group');
@@ -90,9 +90,9 @@ module.exports = async (ctx) => {
items.push(data);
}
- ctx.state.data = {
+ ctx.set('data', {
title: '哔嘀影视',
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/behance/user.js b/lib/v2/behance/user.js
index 515b36f12..5b392fd6f 100644
--- a/lib/v2/behance/user.js
+++ b/lib/v2/behance/user.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const user = ctx.params.user ?? '';
- const type = ctx.params.type ?? 'projects';
+ const user = ctx.req.param('user') ?? '';
+ const type = ctx.req.param('type') ?? 'projects';
const response = await got({
method: 'get',
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
url,
});
const articleHtml = response2.data;
- const $2 = cheerio.load(articleHtml);
+ const $2 = load(articleHtml);
$2('.ImageElement-root-kir').remove();
$2('.embed-dimensions').remove();
$2('script.js-lightbox-slide-content').each((_, elem) => {
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
return description;
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${data.profile.owner.first_name} ${data.profile.owner.last_name}'s ${type}`,
link: data.profile.owner.url,
item: list.map((item, index) => {
@@ -63,5 +63,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.published_on * 1000),
};
}),
- };
+ });
};
diff --git a/lib/v2/bellroy/new-releases.js b/lib/v2/bellroy/new-releases.js
index 1a459e8bd..3ec8d9076 100644
--- a/lib/v2/bellroy/new-releases.js
+++ b/lib/v2/bellroy/new-releases.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
const host = 'https://bellroy.com';
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
});
const data = response.data.products;
- ctx.state.data = {
+ ctx.set('data', {
title: 'Bellroy - New Releases',
link: 'https://bellroy.com/collection/new-releases',
description: 'Bellroy - New Releases',
@@ -22,5 +22,5 @@ module.exports = async (ctx) => {
title: item.attributes.name + ' - ' + item.attributes.dimensions.color,
link: host + item.attributes.canonical_uri,
})),
- };
+ });
};
diff --git a/lib/v2/bendibao/news.js b/lib/v2/bendibao/news.js
index 78ca28a4a..562118c78 100644
--- a/lib/v2/bendibao/news.js
+++ b/lib/v2/bendibao/news.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const { isValidHost } = require('@/utils/valid-host');
module.exports = async (ctx) => {
- const city = ctx.params.city;
+ const city = ctx.req.param('city');
if (!isValidHost(city)) {
throw new Error('Invalid city');
}
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
url: rootUrl,
});
- let $ = cheerio.load(response.data);
+ let $ = load(response.data);
const title =
$('title')
.text()
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
url: `http://${city}.bendibao.com/news`,
});
- $ = cheerio.load(response.data);
+ $ = load(response.data);
items = $('#listNewsTimeLy div.info')
.toArray()
@@ -74,7 +74,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
// Some links lead to mobile-view pages.
// eg. http://m.bj.bendibao.com/news/273517.html
@@ -101,9 +101,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title,
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bgmlist/onair.js b/lib/v2/bgmlist/onair.js
index 59662b32f..d81e4c9a1 100644
--- a/lib/v2/bgmlist/onair.js
+++ b/lib/v2/bgmlist/onair.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
module.exports = async (ctx) => {
const { lang } = ctx.params;
const { data: sites } = await got('https://bgmlist.com/api/v1/bangumi/site');
const { data } = await got('https://bgmlist.com/api/v1/bangumi/onair');
- ctx.state.data = {
+ ctx.set('data', {
title: '番组放送 开播提醒',
link: 'https://bgmlist.com/',
item: data.items.map((item) => {
@@ -28,5 +28,5 @@ module.exports = async (ctx) => {
guid: item.id,
};
}),
- };
+ });
};
diff --git a/lib/v2/bigquant/collections.js b/lib/v2/bigquant/collections.js
index 41b1cb4d5..c6677074e 100644
--- a/lib/v2/bigquant/collections.js
+++ b/lib/v2/bigquant/collections.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const md = require('markdown-it')({
html: true,
});
@@ -27,9 +27,9 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.publishedAt),
}));
- ctx.state.data = {
+ ctx.set('data', {
title: '专题报告 - AI量化知识库 - BigQuant',
link: `${rootUrl}/wiki/collections/c6874e5d-7f45-4e90-8cd9-5e43df3b44ef`,
item: items,
- };
+ });
};
diff --git a/lib/v2/bilibili/app.js b/lib/v2/bilibili/app.js
index c78062c1b..34335379b 100644
--- a/lib/v2/bilibili/app.js
+++ b/lib/v2/bilibili/app.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const config = {
android: '安卓版',
@@ -9,7 +9,7 @@ const config = {
};
module.exports = async (ctx) => {
- const id = ctx.params.id || 'android';
+ const id = ctx.req.param('id') || 'android';
const rootUrl = 'https://app.bilibili.com';
const apiUrl = `${rootUrl}/x/v2/version?mobi_app=${id}`;
@@ -25,9 +25,9 @@ module.exports = async (ctx) => {
description: `
${item.icon ? `` : ''}`,
link: item.link || item.goto || `https://search.bilibili.com/all?${new URLSearchParams({ keyword: item.keyword })}&from_source=webtop_search`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/link-news.js b/lib/v2/bilibili/link-news.js
index 8596b354c..7e95fbb58 100644
--- a/lib/v2/bilibili/link-news.js
+++ b/lib/v2/bilibili/link-news.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
- const product = ctx.params.product;
+ const product = ctx.req.param('product');
let productTitle = '';
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
});
const data = response.data.data.items;
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili ${productTitle}公告`,
link: `https://link.bilibili.com/p/eden/news#/?tab=${product}&tag=all&page_no=1`,
description: `bilibili ${productTitle}公告`,
@@ -38,5 +38,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.ctime.replace(' ', 'T') + '+08:00').toUTCString(),
link: item.announce_link ?? `https://link.bilibili.com/p/eden/news#/newsdetail?id=${item.id}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/live-area.js b/lib/v2/bilibili/live-area.js
index 303aa900e..ac68314be 100644
--- a/lib/v2/bilibili/live-area.js
+++ b/lib/v2/bilibili/live-area.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
- const areaID = ctx.params.areaID;
- const order = ctx.params.order;
+ const areaID = ctx.req.param('areaID');
+ const order = ctx.req.param('order');
let orderTitle = '';
switch (order) {
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
});
const data = response.data.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `哔哩哔哩直播-${parentTitle}·${areaTitle}分区-${orderTitle}`,
link: areaLink,
description: `哔哩哔哩直播-${parentTitle}·${areaTitle}分区-${orderTitle}`,
@@ -60,5 +60,5 @@ module.exports = async (ctx) => {
guid: `https://live.bilibili.com/${item.roomid} ${item.title}`,
link: `https://live.bilibili.com/${item.roomid}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/live-room.js b/lib/v2/bilibili/live-room.js
index 71402d79f..915c8d999 100644
--- a/lib/v2/bilibili/live-room.js
+++ b/lib/v2/bilibili/live-room.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
module.exports = async (ctx) => {
- let roomID = ctx.params.roomID;
+ let roomID = ctx.req.param('roomID');
// 短号查询长号
if (Number.parseInt(roomID, 10) < 10000) {
@@ -31,11 +31,11 @@ module.exports = async (ctx) => {
});
}
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 直播间开播状态`,
link: `https://live.bilibili.com/${roomID}`,
description: `${name} 直播间开播状态`,
item: liveItem,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/bilibili/live-search.js b/lib/v2/bilibili/live-search.js
index f16f88da1..6321f6523 100644
--- a/lib/v2/bilibili/live-search.js
+++ b/lib/v2/bilibili/live-search.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
const cache = require('./cache');
module.exports = async (ctx) => {
- const key = ctx.params.key;
- const order = ctx.params.order;
+ const key = ctx.req.param('key');
+ const order = ctx.req.param('order');
const urlEncodedKey = encodeURIComponent(key);
let orderTitle = '';
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
});
const data = response.data.data.result.live_room;
- ctx.state.data = {
+ ctx.set('data', {
title: `哔哩哔哩直播-${key}-${orderTitle}`,
link: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
description: `哔哩哔哩直播-${key}-${orderTitle}`,
@@ -44,5 +44,5 @@ module.exports = async (ctx) => {
guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
link: `https://live.bilibili.com/${item.roomid}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/mall-ip.js b/lib/v2/bilibili/mall-ip.js
index daac6ed49..45b1e984a 100644
--- a/lib/v2/bilibili/mall-ip.js
+++ b/lib/v2/bilibili/mall-ip.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const detail = await got({
method: 'get',
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const data = response.data.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `${detail.data.data.name} - 会员购`,
description: detail.data.data.intro,
link: `https://mall.bilibili.com/list.html?ip=${id}`,
@@ -30,5 +30,5 @@ module.exports = async (ctx) => {
description: `${item.name}
¥${item.price}`,
link: item.jumpUrlH5,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/mall-new.js b/lib/v2/bilibili/mall-new.js
index 19474d462..230ed09e8 100644
--- a/lib/v2/bilibili/mall-new.js
+++ b/lib/v2/bilibili/mall-new.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
- const category = ctx.params.category || 0;
+ const category = ctx.req.param('category') || 0;
const response = await got({
method: 'get',
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
const type = response.data.data.vo.cateTabs.find((item) => item.cateType === response.data.data.vo.currentCateType).cateName;
- ctx.state.data = {
+ ctx.set('data', {
title: `会员购新品上架-${type}`,
link: 'https://mall.bilibili.com/newdate.html?noTitleBar=1&page=new&from=new_product&loadingShow=1',
item: items.map((item) => ({
@@ -27,5 +27,5 @@ module.exports = async (ctx) => {
description: `${item.name}
${item.priceDesc ? `${item.pricePrefix}${item.priceSymbol}${item.priceDesc[0]}` : ''}
APP 内打开`,
link: item.itemUrlForH5,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/manga-followings.js b/lib/v2/bilibili/manga-followings.js
index a14212cee..a01cf9134 100644
--- a/lib/v2/bilibili/manga-followings.js
+++ b/lib/v2/bilibili/manga-followings.js
@@ -1,16 +1,16 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
-const config = require('@/config').value;
+import { config } from '@/config';
module.exports = async (ctx) => {
- const uid = String(ctx.params.uid);
+ const uid = String(ctx.req.param('uid'));
const name = await cache.getUsernameFromUID(ctx, uid);
const cookie = config.bilibili.cookies[uid];
if (cookie === undefined) {
throw new Error('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
}
- const page_size = ctx.params.limits || 10;
+ const page_size = ctx.req.param('limits') || 10;
const link = 'https://manga.bilibili.com/account-center';
const response = await got({
method: 'POST',
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
}
const comics = response.data.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 的追漫更新 - 哔哩哔哩漫画`,
link,
item: comics.map((item) => ({
@@ -35,5 +35,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.last_ep_publish_time + ' +0800'),
link: `https://manga.bilibili.com/detail/mc${item.comic_id}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/manga-update.js b/lib/v2/bilibili/manga-update.js
index 82d3824e0..c4941bd05 100644
--- a/lib/v2/bilibili/manga-update.js
+++ b/lib/v2/bilibili/manga-update.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
- const comic_id = ctx.params.comicid.startsWith('mc') ? ctx.params.comicid.replace('mc', '') : ctx.params.comicid;
+ const comic_id = ctx.req.param('comicid').startsWith('mc') ? ctx.req.param('comicid').replace('mc', '') : ctx.req.param('comicid');
const link = `https://manga.bilibili.com/detail/mc${comic_id}`;
const response = await got({
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
const data = response.data.data;
const author = data.author_name.join(', ');
- ctx.state.data = {
+ ctx.set('data', {
title: `${data.title} - 哔哩哔哩漫画`,
link,
image: data.vertical_cover,
@@ -29,5 +29,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.pub_time + ' +0800'),
link: `https://manga.bilibili.com/mc${comic_id}/${item.id}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/page.js b/lib/v2/bilibili/page.js
index 82284f981..3fc1ba889 100644
--- a/lib/v2/bilibili/page.js
+++ b/lib/v2/bilibili/page.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
module.exports = async (ctx) => {
- let bvid = ctx.params.bvid;
+ let bvid = ctx.req.param('bvid');
let aid;
if (!bvid.startsWith('BV')) {
aid = bvid;
bvid = null;
}
- const disableEmbed = ctx.params.disableEmbed;
+ const disableEmbed = ctx.req.param('disableEmbed');
const link = `https://www.bilibili.com/video/${bvid || `av${aid}`}`;
const response = await got({
method: 'get',
@@ -20,17 +20,17 @@ module.exports = async (ctx) => {
const { title: name, pages: data } = response.data.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `视频 ${name} 的选集列表`,
link,
description: `视频 ${name} 的视频选集列表`,
item: data
.sort((a, b) => b.page - a.page)
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10)
.map((item) => ({
title: item.part,
description: `${item.part} - ${name}${disableEmbed ? '' : `
${utils.iframe(aid, item.page, bvid)}`}`,
link: `${link}?p=${item.page}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/partion-ranking.js b/lib/v2/bilibili/partion-ranking.js
index 066ed727a..8b6f22086 100644
--- a/lib/v2/bilibili/partion-ranking.js
+++ b/lib/v2/bilibili/partion-ranking.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
const got_ins = got.extend({
headers: {
@@ -15,9 +15,9 @@ function formatDate(now) {
}
module.exports = async (ctx) => {
- const tid = ctx.params.tid;
- const days = ctx.params.days ?? 7;
- const disableEmbed = ctx.params.disableEmbed;
+ const tid = ctx.req.param('tid');
+ const days = ctx.req.param('days') ?? 7;
+ const disableEmbed = ctx.req.param('disableEmbed');
const responseApi = `https://api.bilibili.com/x/web-interface/newlist?ps=15&rid=${tid}&_=${Date.now()}`;
@@ -48,10 +48,10 @@ module.exports = async (ctx) => {
items.push(item);
}
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili ${name} 最热视频`,
link: 'https://www.bilibili.com',
description: `bilibili ${name}分区 最热视频`,
item: items,
- };
+ });
};
diff --git a/lib/v2/bilibili/partion.js b/lib/v2/bilibili/partion.js
index a2c753b10..540902a76 100644
--- a/lib/v2/bilibili/partion.js
+++ b/lib/v2/bilibili/partion.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
module.exports = async (ctx) => {
- const tid = ctx.params.tid;
- const disableEmbed = ctx.params.disableEmbed;
+ const tid = ctx.req.param('tid');
+ const disableEmbed = ctx.req.param('disableEmbed');
const response = await got({
method: 'get',
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
name = list[0].tname;
}
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili ${name}分区`,
link: 'https://www.bilibili.com',
description: `bilibili ${name}分区`,
@@ -32,5 +32,5 @@ module.exports = async (ctx) => {
link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
author: item.owner.name,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/platform.js b/lib/v2/bilibili/platform.js
index c62e6836c..0efb277d5 100644
--- a/lib/v2/bilibili/platform.js
+++ b/lib/v2/bilibili/platform.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { config } from '@/config';
module.exports = async (ctx) => {
const { area = -1, type = '全部类型', uid } = ctx.params;
@@ -35,9 +35,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili会员购票务-${area}`,
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/bilibili/popular.js b/lib/v2/bilibili/popular.js
index 7d7dc02a1..67f66c48d 100644
--- a/lib/v2/bilibili/popular.js
+++ b/lib/v2/bilibili/popular.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
module.exports = async (ctx) => {
- const disableEmbed = ctx.params.disableEmbed;
+ const disableEmbed = ctx.req.param('disableEmbed');
const response = await got({
method: 'get',
url: `https://api.bilibili.com/x/web-interface/popular`,
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
});
const list = response.data.data.list;
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili 综合热门`,
link: 'https://www.bilibili.com',
description: `bilibili 综合热门`,
@@ -25,5 +25,5 @@ module.exports = async (ctx) => {
link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
author: item.owner.name,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/ranking.js b/lib/v2/bilibili/ranking.js
index 8cec5681d..4c4bc259a 100644
--- a/lib/v2/bilibili/ranking.js
+++ b/lib/v2/bilibili/ranking.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
module.exports = async (ctx) => {
- const rid = ctx.params.rid || '0';
- const day = ctx.params.day || '3';
- const arc_type = ctx.params.arc_type || '1';
- const disableEmbed = ctx.params.disableEmbed;
+ const rid = ctx.req.param('rid') || '0';
+ const day = ctx.req.param('day') || '3';
+ const arc_type = ctx.req.param('arc_type') || '1';
+ const disableEmbed = ctx.req.param('disableEmbed');
const arc_type1 = arc_type === '0' ? '全部投稿' : '近期投稿';
const rid_1 = ['0', '1', '168', '3', '129', '4', '36', '188', '160', '119', '155', '5', '181'];
const rid_2 = ['全站', '动画', '国创相关', '音乐', '舞蹈', '游戏', '科技', '数码', '生活', '鬼畜', '时尚', '娱乐', '影视'];
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
list = [...list, ...list[i].others];
}
}
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili ${day}日排行榜-${rid_type}-${arc_type1}`,
link: `https://www.bilibili.com/ranking/all/${rid}/0/${day}`,
item: list.map((item) => ({
@@ -39,5 +39,5 @@ module.exports = async (ctx) => {
author: item.author,
link: !item.create || (new Date(item.create) / 1000 > utils.bvidTime && item.bvid) ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/readlist.js b/lib/v2/bilibili/readlist.js
index 39cdecd95..d1daf11e8 100644
--- a/lib/v2/bilibili/readlist.js
+++ b/lib/v2/bilibili/readlist.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
- const listid = ctx.params.listid;
+ const listid = ctx.req.param('listid');
const listurl = `https://www.bilibili.com/read/readlist/rl${listid}`;
const response = await got({
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
});
const data = response.data.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `bilibili 专栏文集 - ${data.list.name}`,
link: listurl,
image: data.list.image_url,
@@ -27,5 +27,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.publish_time * 1000).toUTCString(),
link: `https://www.bilibili.com/read/cv${item.id}/?from=readlist`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/reply.js b/lib/v2/bilibili/reply.js
index f92dd77b4..67412cf41 100644
--- a/lib/v2/bilibili/reply.js
+++ b/lib/v2/bilibili/reply.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
module.exports = async (ctx) => {
- let bvid = ctx.params.bvid;
+ let bvid = ctx.req.param('bvid');
let aid;
if (!bvid.startsWith('BV')) {
aid = bvid;
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
const data = response.data.data.replies;
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 的 评论`,
link,
description: `${name} 的评论`,
@@ -34,5 +34,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.ctime * 1000).toUTCString(),
link: `${link}/#reply${item.rpid}`,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/user-bangumi.js b/lib/v2/bilibili/user-bangumi.js
index a32d2ca2e..c4eca69bc 100644
--- a/lib/v2/bilibili/user-bangumi.js
+++ b/lib/v2/bilibili/user-bangumi.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
- const type = Number(ctx.params.type || 1);
+ const uid = ctx.req.param('uid');
+ const type = Number(ctx.req.param('type') || 1);
const type_name = ((t) => ['', 'bangumi', 'cinema'][t])(type);
const name = await cache.getUsernameFromUID(ctx, uid);
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
throw new Error(`It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}`);
}
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 的追番列表`,
link: `https://space.bilibili.com/${uid}/${type_name}`,
description: `${name} 的追番列表`,
@@ -32,5 +32,5 @@ module.exports = async (ctx) => {
pubDate: new Date(item.new_ep.pub_time ?? Date.now()).toUTCString(),
link: `https://www.bilibili.com/bangumi/play/` + (item.new_ep.id ? `ep${item.new_ep.id}` : `ss${item.season_id}`),
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/user-channel.js b/lib/v2/bilibili/user-channel.js
index 37ddac9b1..02c91dc36 100644
--- a/lib/v2/bilibili/user-channel.js
+++ b/lib/v2/bilibili/user-channel.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const cache = require('./cache');
const utils = require('./utils');
@@ -8,10 +8,10 @@ const notFoundData = {
};
module.exports = async (ctx) => {
- const uid = Number.parseInt(ctx.params.uid);
- const sid = Number.parseInt(ctx.params.sid);
- const disableEmbed = ctx.params.disableEmbed;
- const limit = ctx.query.limit ?? 25;
+ const uid = Number.parseInt(ctx.req.param('uid'));
+ const sid = Number.parseInt(ctx.req.param('sid'));
+ const disableEmbed = ctx.req.param('disableEmbed');
+ const limit = ctx.req.query('limit') ?? 25;
const link = `https://space.bilibili.com/${uid}/channel/seriesdetail?sid=${sid}`;
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
return;
}
- ctx.state.data = {
+ ctx.set('data', {
title: `${userName} 的 bilibili 频道 ${channelInfo.meta.name}`,
link,
description: `${userName} 的 bilibili 频道`,
@@ -66,5 +66,5 @@ module.exports = async (ctx) => {
author: userName,
};
}),
- };
+ });
};
diff --git a/lib/v2/bilibili/user-collection.js b/lib/v2/bilibili/user-collection.js
index 7f4319fb2..857b9ea10 100644
--- a/lib/v2/bilibili/user-collection.js
+++ b/lib/v2/bilibili/user-collection.js
@@ -1,17 +1,17 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
const utils = require('./utils');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
const notFoundData = {
title: '此 bilibili 频道不存在',
};
module.exports = async (ctx) => {
- const uid = Number.parseInt(ctx.params.uid);
- const sid = Number.parseInt(ctx.params.sid);
- const disableEmbed = ctx.params.disableEmbed;
- const limit = ctx.query.limit ?? 25;
+ const uid = Number.parseInt(ctx.req.param('uid'));
+ const sid = Number.parseInt(ctx.req.param('sid'));
+ const disableEmbed = ctx.req.param('disableEmbed');
+ const limit = ctx.req.query('limit') ?? 25;
const link = `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`;
const [userName, face] = await cache.getUsernameAndFaceFromUID(ctx, uid);
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
return;
}
- ctx.state.data = {
+ ctx.set('data', {
title: `${userName} 的 bilibili 合集 ${data.meta.name}`,
link,
description: `${userName} 的 bilibili 合集`,
@@ -49,5 +49,5 @@ module.exports = async (ctx) => {
author: userName,
};
}),
- };
+ });
};
diff --git a/lib/v2/bilibili/user-fav.js b/lib/v2/bilibili/user-fav.js
index 43ff88df8..de2ecfc11 100644
--- a/lib/v2/bilibili/user-fav.js
+++ b/lib/v2/bilibili/user-fav.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
const utils = require('./utils');
-const config = require('@/config').value;
+import { config } from '@/config';
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
- const disableEmbed = ctx.params.disableEmbed;
+ const uid = ctx.req.param('uid');
+ const disableEmbed = ctx.req.param('disableEmbed');
const name = await cache.getUsernameFromUID(ctx, uid);
const response = await got({
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
});
const data = response.data;
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 的 bilibili 收藏夹`,
link: `https://space.bilibili.com/${uid}/#/favlist`,
description: `${name} 的 bilibili 收藏夹`,
@@ -33,5 +33,5 @@ module.exports = async (ctx) => {
link: item.fav_at > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
author: item.owner.name,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/utils.js b/lib/v2/bilibili/utils.js
index 24cea3048..a84b88a41 100644
--- a/lib/v2/bilibili/utils.js
+++ b/lib/v2/bilibili/utils.js
@@ -1,5 +1,5 @@
-const config = require('@/config').value;
-const md5 = require('@/utils/md5');
+import { config } from '@/config';
+import md5 from '@/utils/md5';
const CryptoJS = require('crypto-js');
function iframe(aid, page, bvid) {
diff --git a/lib/v2/bilibili/video-all.js b/lib/v2/bilibili/video-all.js
index 54af3f9a4..54d120956 100644
--- a/lib/v2/bilibili/video-all.js
+++ b/lib/v2/bilibili/video-all.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
const utils = require('./utils');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
- const disableEmbed = ctx.params.disableEmbed;
+ const uid = ctx.req.param('uid');
+ const disableEmbed = ctx.req.param('disableEmbed');
const cookie = await cache.getCookie(ctx);
const wbiVerifyString = await cache.getWbiVerifyString(ctx);
const dmImgList = utils.getDmImgList();
@@ -57,7 +57,7 @@ module.exports = async (ctx) => {
}
}
- ctx.state.data = {
+ ctx.set('data', {
title: name,
link: `https://space.bilibili.com/${uid}/video`,
description: `${name} 的 bilibili 所有视频`,
@@ -71,5 +71,5 @@ module.exports = async (ctx) => {
author: name,
comments: item.comment,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/video.js b/lib/v2/bilibili/video.js
index 7d34717be..3835d7a03 100644
--- a/lib/v2/bilibili/video.js
+++ b/lib/v2/bilibili/video.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
const utils = require('./utils');
const logger = require('@/utils/logger');
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
- const disableEmbed = ctx.params.disableEmbed;
+ const uid = ctx.req.param('uid');
+ const disableEmbed = ctx.req.param('disableEmbed');
const cookie = await cache.getCookie(ctx);
const wbiVerifyString = await cache.getWbiVerifyString(ctx);
const dmImgList = utils.getDmImgList();
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
}
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 的 bilibili 空间`,
link: `https://space.bilibili.com/${uid}`,
description: `${name} 的 bilibili 空间`,
@@ -48,5 +48,5 @@ module.exports = async (ctx) => {
author: name,
comments: item.comment,
})),
- };
+ });
};
diff --git a/lib/v2/bilibili/vsearch.js b/lib/v2/bilibili/vsearch.js
index 349f0bceb..ba0cc6976 100644
--- a/lib/v2/bilibili/vsearch.js
+++ b/lib/v2/bilibili/vsearch.js
@@ -1,17 +1,17 @@
-const config = require('@/config').value;
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import { config } from '@/config';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const utils = require('./utils');
const { CookieJar } = require('tough-cookie');
const cookieJar = new CookieJar();
const { queryToBoolean } = require('@/utils/readable-social');
module.exports = async (ctx) => {
- const kw = ctx.params.kw;
- const order = ctx.params.order || 'pubdate';
- const disableEmbed = queryToBoolean(ctx.params.disableEmbed);
+ const kw = ctx.req.param('kw');
+ const order = ctx.req.param('order') || 'pubdate';
+ const disableEmbed = queryToBoolean(ctx.req.param('disableEmbed'));
const kw_url = encodeURIComponent(kw);
- const tids = ctx.params.tid ?? 0;
+ const tids = ctx.req.param('tid') ?? 0;
const data = await ctx.cache.tryGet(
`bilibili:vsearch:${tids}:${kw}:${order}`,
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
false
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${kw} - bilibili`,
link: `https://search.bilibili.com/all?keyword=${kw}&order=${order}`,
description: `Result from ${kw} bilibili search, ordered by ${order}.`,
@@ -68,5 +68,5 @@ module.exports = async (ctx) => {
link: item.arcurl,
};
}),
- };
+ });
};
diff --git a/lib/v2/bilibili/watchlater.js b/lib/v2/bilibili/watchlater.js
index f6454eb14..30c2a30c0 100644
--- a/lib/v2/bilibili/watchlater.js
+++ b/lib/v2/bilibili/watchlater.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const cache = require('./cache');
-const config = require('@/config').value;
+import { config } from '@/config';
const utils = require('./utils');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const uid = ctx.params.uid;
- const disableEmbed = ctx.params.disableEmbed;
+ const uid = ctx.req.param('uid');
+ const disableEmbed = ctx.req.param('disableEmbed');
const name = await cache.getUsernameFromUID(ctx, uid);
const cookie = config.bilibili.cookies[uid];
@@ -36,9 +36,9 @@ module.exports = async (ctx) => {
author: item.owner.name,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${name} 稍后再看`,
link: 'https://www.bilibili.com/watchlater#/list',
item: out,
- };
+ });
};
diff --git a/lib/v2/bilibili/weekly-recommend.js b/lib/v2/bilibili/weekly-recommend.js
index ae616b75d..2e1a12d92 100644
--- a/lib/v2/bilibili/weekly-recommend.js
+++ b/lib/v2/bilibili/weekly-recommend.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const utils = require('./utils');
module.exports = async (ctx) => {
- const disableEmbed = ctx.params.disableEmbed;
+ const disableEmbed = ctx.req.param('disableEmbed');
const status_response = await got({
method: 'get',
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
});
const data = response.data.data.list;
- ctx.state.data = {
+ ctx.set('data', {
title: 'B站每周必看',
link: 'https://www.bilibili.com/h5/weekly-recommend',
description: 'B站每周必看',
@@ -37,5 +37,5 @@ module.exports = async (ctx) => {
`,
link: weekly_number > 60 && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.param}`,
})),
- };
+ });
};
diff --git a/lib/v2/bing/daily-wallpaper.js b/lib/v2/bing/daily-wallpaper.js
index 3d8196e1b..ccee8f790 100644
--- a/lib/v2/bing/daily-wallpaper.js
+++ b/lib/v2/bing/daily-wallpaper.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
const response = await got({
@@ -8,12 +8,12 @@ module.exports = async (ctx) => {
searchParams: {
format: 'js',
idx: 0,
- n: ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 7,
+ n: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 7,
mkt: 'zh-CN',
},
});
const data = response.data;
- ctx.state.data = {
+ ctx.set('data', {
title: 'Bing每日壁纸',
link: 'https://cn.bing.com/',
item: data.images.map((item) => ({
@@ -21,5 +21,5 @@ module.exports = async (ctx) => {
description: ``,
link: item.copyrightlink,
})),
- };
+ });
};
diff --git a/lib/v2/bing/search.js b/lib/v2/bing/search.js
index 41c021da7..313c242d4 100644
--- a/lib/v2/bing/search.js
+++ b/lib/v2/bing/search.js
@@ -1,12 +1,12 @@
const parser = require('@/utils/rss-parser');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
const dayjs = require('dayjs');
const localizedFormat = require('dayjs/plugin/localizedFormat');
require('dayjs/locale/zh-cn');
dayjs.extend(localizedFormat);
module.exports = async (ctx) => {
- const q = ctx.params.keyword;
+ const q = ctx.req.param('keyword');
const searchParams = new URLSearchParams({
format: 'rss',
q,
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const url = new URL('https://cn.bing.com/search');
url.search = searchParams.toString();
const data = await parser.parseURL(url.toString());
- ctx.state.data = {
+ ctx.set('data', {
title: data.title,
link: data.link,
description: data.description + ' - ' + data.copyright,
@@ -24,5 +24,5 @@ module.exports = async (ctx) => {
description: e.content,
pubDate: parseDate(e.pubDate, 'dddd, DD MMM YYYY HH:mm:ss [GMT]', 'zh-cn'),
})),
- };
+ });
};
diff --git a/lib/v2/biodiscover/index.js b/lib/v2/biodiscover/index.js
index 5369c364e..8eb54223f 100644
--- a/lib/v2/biodiscover/index.js
+++ b/lib/v2/biodiscover/index.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const channel = ctx.params.channel;
+ const channel = ctx.req.param('channel');
const listUrl = 'http://www.biodiscover.com/' + channel;
const response = await got({ url: listUrl });
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('.new_list .newList_box')
.map((_, item) => ({
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
}))
.toArray();
- ctx.state.data = {
+ ctx.set('data', {
title: '生物探索 - ' + $('.header li.sel a').text(),
link: listUrl,
description: $('meta[name=description]').attr('content'),
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({ url: item.link });
- const $ = cheerio.load(detailResponse.data);
+ const $ = load(detailResponse.data);
// remove sharing info if exists
const lastNode = $('.main_info').children().last();
@@ -40,5 +40,5 @@ module.exports = async (ctx) => {
})
)
),
- };
+ });
};
diff --git a/lib/v2/bioone/featured.js b/lib/v2/bioone/featured.js
index 0ecc7dfa7..4d17bd6bd 100644
--- a/lib/v2/bioone/featured.js
+++ b/lib/v2/bioone/featured.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://bioone.org';
@@ -10,10 +10,10 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.items h4 a')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10)
.toArray()
.map((item) => {
item = $(item);
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
rejectUnauthorized: false,
},
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('#divARTICLECONTENTTop').html();
item.doi = content('meta[name="dc.Identifier"]').attr('content');
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: 'Featured articles - BioOne',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bioone/journal.js b/lib/v2/bioone/journal.js
index 7c47f5180..5035aeb85 100644
--- a/lib/v2/bioone/journal.js
+++ b/lib/v2/bioone/journal.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const journal = ctx.params.journal ?? 'acta-chiropterologica';
+ const journal = ctx.req.param('journal') ?? 'acta-chiropterologica';
const rootUrl = 'https://bioone.org';
const currentUrl = `${rootUrl}/journals/${journal}/current`;
@@ -13,10 +13,10 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.TOCLineItemBoldText')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 20)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20)
.toArray()
.map((item) => {
item = $(item).parent();
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
},
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.ProceedingsArticleOpenAccessPanel').remove();
content('#divNotSignedSection, #rightRail').remove();
@@ -51,10 +51,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('.panel-body .row a').first().text()} - BioOne`,
description: $('.panel-body .row text').first().text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/biquge/index.js b/lib/v2/biquge/index.js
index ad2f2fd49..4cb61217a 100644
--- a/lib/v2/biquge/index.js
+++ b/lib/v2/biquge/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const config = require('@/config').value;
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { config } from '@/config';
const allowHost = new Set([
'www.xbiquwx.la',
'www.biqu5200.net',
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
const rootUrl = ctx.path.split('/').slice(1, 4).join('/');
const currentUrl = ctx.path.slice(1);
if (!config.feature.allow_user_supply_unsafe_domain && !allowHost.has(new URL(rootUrl).hostname)) {
- ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
+ throw new Error(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
const response = await got({
@@ -41,14 +41,14 @@ module.exports = async (ctx) => {
const isGBK = /charset="?'?gb/i.test(response.data.toString());
const encoding = isGBK ? 'gbk' : 'utf-8';
- const $ = cheerio.load(iconv.decode(response.data, encoding));
+ const $ = load(iconv.decode(response.data, encoding));
const author = $('meta[property="og:novel:author"]').attr('content');
const pubDate = timezone(parseDate($('meta[property="og:novel:update_time"]').attr('content')), +8);
let items = $('dl dd a')
.toArray()
.reverse()
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 1)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 1)
.map((item) => {
item = $(item);
@@ -82,7 +82,7 @@ module.exports = async (ctx) => {
},
});
- const content = cheerio.load(iconv.decode(detailResponse.data, encoding));
+ const content = load(iconv.decode(detailResponse.data, encoding));
item.description = content('#content').html();
@@ -91,9 +91,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('meta[property="og:title"]').attr('content')} - 笔趣阁`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bit/cs/cs.js b/lib/v2/bit/cs/cs.js
index 23b45fbb5..2bc4c2ef0 100644
--- a/lib/v2/bit/cs/cs.js
+++ b/lib/v2/bit/cs/cs.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const util = require('./utils');
module.exports = async (ctx) => {
@@ -9,16 +9,16 @@ module.exports = async (ctx) => {
url: link,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.box_list01 li').toArray();
const result = await util.ProcessFeed(list, ctx.cache);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link,
description: $('meta[name="description"]').attr('content'),
item: result,
- };
+ });
};
diff --git a/lib/v2/bit/cs/utils.js b/lib/v2/bit/cs/utils.js
index df40bde54..5d981db7e 100644
--- a/lib/v2/bit/cs/utils.js
+++ b/lib/v2/bit/cs/utils.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
// 专门定义一个function用于加载文章内容
-async function load(item) {
+async function loadContent(item) {
// 异步请求文章
const response = await got(item.link);
// 加载文章内容
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
// 提取作者
const zuozhe = $('.zuozhe').children().next();
@@ -27,7 +27,7 @@ const ProcessFeed = (list, caches) => {
return Promise.all(
// 遍历每一篇文章
list.map((item) => {
- const $ = cheerio.load(item);
+ const $ = load(item);
const $title = $('a');
// 还原相对链接为绝对链接
@@ -43,7 +43,7 @@ const ProcessFeed = (list, caches) => {
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
- return caches.tryGet(single.link, () => load(single));
+ return caches.tryGet(single.link, () => loadContent(single));
})
);
};
diff --git a/lib/v2/bit/jwc/jwc.js b/lib/v2/bit/jwc/jwc.js
index 176f91549..853da95ae 100644
--- a/lib/v2/bit/jwc/jwc.js
+++ b/lib/v2/bit/jwc/jwc.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const util = require('./utils');
module.exports = async (ctx) => {
@@ -9,16 +9,16 @@ module.exports = async (ctx) => {
url: link,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('li.gpTextArea').toArray();
const result = await util.ProcessFeed(list, ctx.cache);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link,
description: '北京理工大学教务部',
item: result,
- };
+ });
};
diff --git a/lib/v2/bit/jwc/utils.js b/lib/v2/bit/jwc/utils.js
index 4cd762be6..4a2555506 100644
--- a/lib/v2/bit/jwc/utils.js
+++ b/lib/v2/bit/jwc/utils.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
// 专门定义一个function用于加载文章内容
-async function load(item) {
+async function loadContent(item) {
// 异步请求文章
const response = await got(item.link);
// 加载文章内容
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
// 提取内容
item.description = $('.gp-article').html();
@@ -23,7 +23,7 @@ const ProcessFeed = (list, caches) => {
return Promise.all(
// 遍历每一篇文章
list.map((item) => {
- const $ = cheerio.load(item);
+ const $ = load(item);
const $title = $('a');
// 还原相对链接为绝对链接
@@ -39,7 +39,7 @@ const ProcessFeed = (list, caches) => {
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
- return caches.tryGet(single.link, () => load(single));
+ return caches.tryGet(single.link, () => loadContent(single));
})
);
};
diff --git a/lib/v2/bit/rszhaopin.js b/lib/v2/bit/rszhaopin.js
index e5e6a940f..c2164bcac 100644
--- a/lib/v2/bit/rszhaopin.js
+++ b/lib/v2/bit/rszhaopin.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://rszhaopin.bit.edu.cn';
@@ -22,9 +22,9 @@ module.exports = async (ctx) => {
link: `${rootUrl}/zp.html#/notice/${item.id}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: '人才招聘 - 北京理工大学',
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bit/yjs.js b/lib/v2/bit/yjs.js
index 70f14f8e4..428096151 100644
--- a/lib/v2/bit/yjs.js
+++ b/lib/v2/bit/yjs.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const link = 'https://grd.bit.edu.cn/zsgz/zsxx/index.htm';
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.tongzhigonggao li');
- ctx.state.data = {
+ ctx.set('data', {
title: '北京理工大学研究生院',
link,
description: '北京理工大学研究生院通知公告',
@@ -23,5 +23,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.find('span').text(), 'YYYY-MM-DD'),
};
}),
- };
+ });
};
diff --git a/lib/v2/bitbucket/commits.js b/lib/v2/bitbucket/commits.js
index f590281ea..cae9c0121 100644
--- a/lib/v2/bitbucket/commits.js
+++ b/lib/v2/bitbucket/commits.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { config } from '@/config';
const queryString = require('query-string');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const workspace = ctx.params.workspace;
- const repo_slug = ctx.params.repo_slug;
+ const workspace = ctx.req.param('workspace');
+ const repo_slug = ctx.req.param('repo_slug');
const headers = {
Accept: 'application/json',
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
headers,
});
const data = response.data.values;
- ctx.state.data = {
+ ctx.set('data', {
allowEmpty: true,
title: `Recent Commits to ${workspace}/${repo_slug}`,
link: `https://bitbucket.org/${workspace}/${repo_slug}`,
@@ -36,5 +36,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.date),
link: item.links.html.href,
})),
- };
+ });
};
diff --git a/lib/v2/bitbucket/tags.js b/lib/v2/bitbucket/tags.js
index abb346f87..e123587d8 100644
--- a/lib/v2/bitbucket/tags.js
+++ b/lib/v2/bitbucket/tags.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { config } from '@/config';
const queryString = require('query-string');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const workspace = ctx.params.workspace;
- const repo_slug = ctx.params.repo_slug;
+ const workspace = ctx.req.param('workspace');
+ const repo_slug = ctx.req.param('repo_slug');
const headers = {
Accept: 'application/json',
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
headers,
});
const data = response.data.values;
- ctx.state.data = {
+ ctx.set('data', {
allowEmpty: true,
title: `Recent Tags in ${workspace}/${repo_slug}`,
link: `https://bitbucket.org/${workspace}/${repo_slug}`,
@@ -36,5 +36,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.date),
link: item.links.html.href,
})),
- };
+ });
};
diff --git a/lib/v2/bitmovin/blog.js b/lib/v2/bitmovin/blog.js
index 23a8e81a4..cea9b41c2 100644
--- a/lib/v2/bitmovin/blog.js
+++ b/lib/v2/bitmovin/blog.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://bitmovin.com';
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
const apiUrl = `${baseUrl}/wp-json/wp/v2`;
const { data } = await got(`${apiUrl}/posts`, {
searchParams: {
- per_page: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 100,
+ per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100,
},
});
@@ -19,9 +19,9 @@ module.exports = async (ctx) => {
link: item.link,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'Blog - Bitmovin',
link: `${baseUrl}/blog/`,
item: items,
- };
+ });
};
diff --git a/lib/v2/bjfu/grs.js b/lib/v2/bjfu/grs.js
index fd61c43f4..9eafd7996 100644
--- a/lib/v2/bjfu/grs.js
+++ b/lib/v2/bjfu/grs.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const url = 'http://graduate.bjfu.edu.cn/pygl/pydt/index.html';
const response = await got.get(url);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('.itemList li')
.slice(0, 11)
.toArray()
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const itemReponse = await got.get(item.link);
const data = itemReponse.data;
- const itemElement = cheerio.load(data);
+ const itemElement = load(data);
item.description = itemElement('.articleTxt').html();
@@ -43,9 +43,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '北林研培养动态',
link: url,
item: result,
- };
+ });
};
diff --git a/lib/v2/bjfu/it/index.js b/lib/v2/bjfu/it/index.js
index 50bfd092f..b7d313468 100644
--- a/lib/v2/bjfu/it/index.js
+++ b/lib/v2/bjfu/it/index.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const util = require('./utils');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
let title, path;
switch (type) {
case 'kydt':
@@ -32,20 +32,20 @@ module.exports = async (ctx) => {
});
const data = response.data;
- let $ = cheerio.load(iconv.decode(data, 'utf-8'));
+ let $ = load(iconv.decode(data, 'utf-8'));
const charset = $('meta[charset]').attr('charset');
if (charset?.toLowerCase() !== 'utf-8') {
- $ = cheerio.load(iconv.decode(data, charset ?? 'utf-8'));
+ $ = load(iconv.decode(data, charset ?? 'utf-8'));
}
const list = $('.item-content').toArray();
const result = await util.ProcessFeed(base, list, ctx.cache); // 感谢@hoilc指导
- ctx.state.data = {
+ ctx.set('data', {
title: '北林信息 - ' + title,
link: 'http://it.bjfu.edu.cn/' + path,
description: '北京林业大学信息学院 - ' + title,
item: result,
- };
+ });
};
diff --git a/lib/v2/bjfu/it/utils.js b/lib/v2/bjfu/it/utils.js
index bc851fd3f..dec126b66 100644
--- a/lib/v2/bjfu/it/utils.js
+++ b/lib/v2/bjfu/it/utils.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
// 完整文章页
-async function load(link) {
+async function loadContent(link) {
let response;
try {
response = await got.get(link, {
@@ -18,10 +18,10 @@ async function load(link) {
const data = response.data; // 不用转码
// 加载文章内容
- let $ = cheerio.load(iconv.decode(data, 'utf-8'));
+ let $ = load(iconv.decode(data, 'utf-8'));
const charset = $('meta[charset]').attr('charset');
if (charset?.toLowerCase() !== 'utf-8') {
- $ = cheerio.load(iconv.decode(data, charset ?? 'utf-8'));
+ $ = load(iconv.decode(data, charset ?? 'utf-8'));
}
// 提取内容
@@ -36,7 +36,7 @@ const ProcessFeed = (base, list, caches) =>
Promise.all(
// 遍历每一篇文章
list.map((item) => {
- const $ = cheerio.load(item);
+ const $ = load(item);
const $title = $('a');
// 还原相对链接为绝对链接
@@ -55,7 +55,7 @@ const ProcessFeed = (base, list, caches) =>
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
return caches.tryGet(itemUrl, async () => {
- const { description } = await load(itemUrl);
+ const { description } = await loadContent(itemUrl);
// 列表上提取到的信息
return {
diff --git a/lib/v2/bjfu/jwc/index.js b/lib/v2/bjfu/jwc/index.js
index 6d195029c..09fbf7629 100644
--- a/lib/v2/bjfu/jwc/index.js
+++ b/lib/v2/bjfu/jwc/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const util = require('./utils');
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
let title, path;
switch (type) {
case 'jgdt':
@@ -35,16 +35,16 @@ module.exports = async (ctx) => {
});
const data = response.data; // 不用转码
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('.list_c li').slice(0, 15).toArray();
const result = await util.ProcessFeed(base, list, ctx.cache); // 感谢@hoilc指导
- ctx.state.data = {
+ ctx.set('data', {
title: '北林教务处 - ' + title,
link: 'http://jwc.bjfu.edu.cn/' + path,
description: '北京林业大学教务处 - ' + title,
item: result,
- };
+ });
};
diff --git a/lib/v2/bjfu/jwc/utils.js b/lib/v2/bjfu/jwc/utils.js
index e997c6540..107b54a6c 100644
--- a/lib/v2/bjfu/jwc/utils.js
+++ b/lib/v2/bjfu/jwc/utils.js
@@ -1,16 +1,16 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
// 完整文章页
-async function load(link) {
+async function loadContent(link) {
const response = await got.get(link);
const data = response.data; // 不用转码
// 加载文章内容
- const $ = cheerio.load(data);
+ const $ = load(data);
// 提取内容
const description = ($('#con_c').length ? $('#con_c').html() : '') + ($('#con_fujian').length ? $('#con_fujian').html() : '');
@@ -23,7 +23,7 @@ const ProcessFeed = (base, list, caches) =>
Promise.all(
// 遍历每一篇文章
list.map((item) => {
- const $ = cheerio.load(item);
+ const $ = load(item);
const $title = $('a');
// 还原相对链接为绝对链接
@@ -42,7 +42,7 @@ const ProcessFeed = (base, list, caches) =>
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
return caches.tryGet(itemUrl, async () => {
- const { description } = await load(itemUrl);
+ const { description } = await loadContent(itemUrl);
// 列表上提取到的信息
return {
diff --git a/lib/v2/bjfu/kjc.js b/lib/v2/bjfu/kjc.js
index 0e2a5f1ff..6b2460469 100644
--- a/lib/v2/bjfu/kjc.js
+++ b/lib/v2/bjfu/kjc.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const url = 'http://kyc.bjfu.edu.cn/tztg/index.html';
const response = await got.get(url);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('.ll_con_r_b li')
.slice(0, 15)
.toArray()
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const itemReponse = await got.get(item.link);
const data = itemReponse.data;
- const itemElement = cheerio.load(data);
+ const itemElement = load(data);
item.description = itemElement('#a_con_l_con').html();
item.title = item.title.includes('...') ? itemElement('#a_con_l_title').text() : item.title;
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '北林科技处通知',
link: url,
item: result,
- };
+ });
};
diff --git a/lib/v2/bjfu/news/index.js b/lib/v2/bjfu/news/index.js
index 0d0d2f147..b2947a91b 100644
--- a/lib/v2/bjfu/news/index.js
+++ b/lib/v2/bjfu/news/index.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const util = require('./utils');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
let title, path;
switch (type) {
case 'xydt':
@@ -37,22 +37,22 @@ module.exports = async (ctx) => {
});
const data = response.data;
- let $ = cheerio.load(iconv.decode(data, 'utf-8'));
+ let $ = load(iconv.decode(data, 'utf-8'));
const charset = $('meta[http-equiv="Content-Type"]')
.attr('content')
.match(/charset=(.*)/)?.[1];
if (charset?.toLowerCase() !== 'utf-8') {
- $ = cheerio.load(iconv.decode(data, charset ?? 'utf-8'));
+ $ = load(iconv.decode(data, charset ?? 'utf-8'));
}
const list = $('.news_ul li').slice(0, 12).toArray();
const result = await util.ProcessFeed(base, list, ctx.cache); // 感谢@hoilc指导
- ctx.state.data = {
+ ctx.set('data', {
title: '北林新闻- ' + title,
link: 'http://news.bjfu.edu.cn/' + path,
description: '绿色新闻网 - ' + title,
item: result,
- };
+ });
};
diff --git a/lib/v2/bjfu/news/utils.js b/lib/v2/bjfu/news/utils.js
index 083724b73..7c402246d 100644
--- a/lib/v2/bjfu/news/utils.js
+++ b/lib/v2/bjfu/news/utils.js
@@ -1,16 +1,16 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
// 完整文章页
-async function load(link) {
+async function loadContent(link) {
const response = await got.get(link);
const data = response.data; // 不用转码
// 加载文章内容
- const $ = cheerio.load(data);
+ const $ = load(data);
// 解析日期
const pubDate = timezone(
@@ -34,7 +34,7 @@ const ProcessFeed = (base, list, caches) =>
Promise.all(
// 遍历每一篇文章
list.map((item) => {
- const $ = cheerio.load(item);
+ const $ = load(item);
const $title = $('a');
// 还原相对链接为绝对链接
@@ -43,7 +43,7 @@ const ProcessFeed = (base, list, caches) =>
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
return caches.tryGet(itemUrl, async () => {
- const { description, pubDate, title } = await load(itemUrl);
+ const { description, pubDate, title } = await loadContent(itemUrl);
// 列表上提取到的信息
return {
diff --git a/lib/v2/bjp/apod.js b/lib/v2/bjp/apod.js
index 0a1eedd7a..5745bd740 100644
--- a/lib/v2/bjp/apod.js
+++ b/lib/v2/bjp/apod.js
@@ -1,7 +1,7 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const baseUrl = 'https://www.bjp.org.cn';
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const res = await got(listUrl);
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const list = $('td[align=left] b')
.toArray()
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
list.map((e) =>
ctx.cache.tryGet(e.link, async () => {
const { data } = await got.get(e.link);
- const $ = cheerio.load(data);
+ const $ = load(data);
e.description = $('.juzhong').html();
@@ -34,10 +34,10 @@ module.exports = async (ctx) => {
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
description: '探索宇宙!每天发布一张迷人宇宙的影像,以及由专业天文学家撰写的简要说明。',
link: listUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bjsk/index.js b/lib/v2/bjsk/index.js
index 4eb2ecfc4..0a96604e6 100644
--- a/lib/v2/bjsk/index.js
+++ b/lib/v2/bjsk/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://www.bjsk.org.cn';
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
rejectUnauthorized: false,
},
});
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = $('.article-list a')
.toArray()
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
rejectUnauthorized: false,
},
});
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = $('.article-main').html();
item.author = $('.info')
.text()
@@ -43,10 +43,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link,
image: 'https://www.bjsk.org.cn/favicon.ico',
item: items,
- };
+ });
};
diff --git a/lib/v2/bjsk/keti.js b/lib/v2/bjsk/keti.js
index 07a3638dd..55623849c 100644
--- a/lib/v2/bjsk/keti.js
+++ b/lib/v2/bjsk/keti.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '402881027cbb8c6f017cbb8e17710002';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 100;
+ const id = ctx.req.param('id') ?? '402881027cbb8c6f017cbb8e17710002';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100;
const rootUrl = 'https://keti.bjsk.org.cn';
const currentUrl = `${rootUrl}/articleAction!to_moreList.action?entity.columnId=${id}&pagination.pageSize=${limit}`;
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('a.news')
.toArray()
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.d_text').html();
item.author = content('div.d_information p span').last().text();
@@ -46,9 +46,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `北京社科基金项目管理平台 - ${$('.noticetop').text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bjwxdxh/index.js b/lib/v2/bjwxdxh/index.js
index 0791c0265..f2109aa53 100644
--- a/lib/v2/bjwxdxh/index.js
+++ b/lib/v2/bjwxdxh/index.js
@@ -1,11 +1,11 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'http://www.bjwxdxh.org.cn';
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
const link = type ? `${baseUrl}/news/class/?${type}.html` : `${baseUrl}/news/class/`;
const response = await got({
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
url: link,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('div#newsquery > ul > li')
.map((_, item) => {
item = $(item);
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(response.data);
+ const content = load(response.data);
const info = content('div.info')
.text()
.match(/作者:(.*?)\s+发布于:(.*?\s+.*?)\s/);
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link,
item: list,
- };
+ });
};
diff --git a/lib/v2/bjx/huanbao.js b/lib/v2/bjx/huanbao.js
index 85b4af6c1..7fe2664a8 100644
--- a/lib/v2/bjx/huanbao.js
+++ b/lib/v2/bjx/huanbao.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
const asyncPool = require('tiny-async-pool');
const asyncPoolAll = async (...args) => {
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
const listURL = 'https://huanbao.bjx.com.cn/yw/';
const response = await got(listURL);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.cc-layout-3 .cc-list-content li')
.toArray()
.map((e) => {
@@ -35,11 +35,11 @@ module.exports = async (ctx) => {
(items) => fetchPage(ctx, items.link)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '北极星环保 - 环保行业垂直门户网站',
link: listURL,
item: items,
- };
+ });
};
const fetchPage = (ctx, link) =>
@@ -48,7 +48,7 @@ const fetchPage = (ctx, link) =>
const pages = [];
const result = await got(link);
- const $page = cheerio.load(result.data);
+ const $page = load(result.data);
pages.push($page);
// 如果是有分页链接,则使用顺序加载以保证顺序
@@ -63,7 +63,7 @@ const fetchPage = (ctx, link) =>
const sublink = new URL($a.attr('href'), link).href;
/* eslint-disable no-await-in-loop */
const result = await got(sublink);
- pages.push(cheerio.load(result.data));
+ pages.push(load(result.data));
}
}
diff --git a/lib/v2/bjx/types.js b/lib/v2/bjx/types.js
index 32b9ffe63..943c3af93 100644
--- a/lib/v2/bjx/types.js
+++ b/lib/v2/bjx/types.js
@@ -1,18 +1,18 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
const response = await got({
method: 'get',
url: `https://guangfu.bjx.com.cn/${type}/`,
});
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const typeName = $('div.box2 em:last').text();
const list = $('div.cc-list-content ul li');
- ctx.state.data = {
+ ctx.set('data', {
title: `北极星太阳能光大网${typeName}`,
description: $('meta[name="Description"]').attr('content'),
link: `https://guangfu.bjx.com.cn/${type}/`,
@@ -29,5 +29,5 @@ module.exports = async (ctx) => {
};
})
.get(),
- };
+ });
};
diff --git a/lib/v2/blizzard/news.js b/lib/v2/blizzard/news.js
index 6570d06ce..9d476b286 100644
--- a/lib/v2/blizzard/news.js
+++ b/lib/v2/blizzard/news.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const category = ctx.params.category || '';
- const language = ctx.params.language || 'en-us';
+ const category = ctx.req.param('category') || '';
+ const language = ctx.req.param('language') || 'en-us';
const rootUrl = 'https://news.blizzard.com';
const currentUrl = `${rootUrl}/${language}/${category}`;
@@ -14,10 +14,10 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response.data.html, null, false);
+ const $ = load(response.data.html, null, false);
const list = $('.FeaturedArticle-text > a, .ArticleListItem > article > a')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30)
.toArray()
.map((item) => {
item = $(item);
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.author = content('.ArticleDetail-bylineAuthor').text();
item.description = content('.ArticleDetail-headingImageBlock').html() + content('.ArticleDetail-content').html();
@@ -42,9 +42,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bloomberg/authors.js b/lib/v2/bloomberg/authors.js
index 99d52681e..51a28192b 100644
--- a/lib/v2/bloomberg/authors.js
+++ b/lib/v2/bloomberg/authors.js
@@ -1,5 +1,5 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
+import { load } from 'cheerio';
+import got from '@/utils/got';
const rssParser = require('@/utils/rss-parser');
const { asyncPoolAll, parseArticle } = require('./utils');
@@ -11,7 +11,7 @@ const parseAuthorNewsList = async (slug) => {
if (!resp.data.html) {
return [];
}
- const $ = cheerio.load(resp.data.html);
+ const $ = load(resp.data.html);
const articles = $('article.story-list-story');
return articles
.map((index, item) => {
@@ -43,10 +43,10 @@ module.exports = async (ctx) => {
const item = await asyncPoolAll(1, list, (item) => parseArticle(item, ctx));
const authorName = item.find((i) => i.author)?.author ?? 'Unknown';
- ctx.state.data = {
+ ctx.set('data', {
title: `Bloomberg - ${authorName}`,
link,
language: 'en-us',
item,
- };
+ });
};
diff --git a/lib/v2/bloomberg/index.js b/lib/v2/bloomberg/index.js
index 9ab105685..250ae7af3 100644
--- a/lib/v2/bloomberg/index.js
+++ b/lib/v2/bloomberg/index.js
@@ -20,9 +20,9 @@ module.exports = async (ctx) => {
const list = await parseNewsList(currentUrl, ctx);
const items = await asyncPoolAll(1, list, (item) => parseArticle(item, ctx));
- ctx.state.data = {
+ ctx.set('data', {
title: `Bloomberg - ${site_title_mapping[site ?? '/']}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bloomberg/utils.js b/lib/v2/bloomberg/utils.js
index db34fc9b8..d2db21389 100644
--- a/lib/v2/bloomberg/utils.js
+++ b/lib/v2/bloomberg/utils.js
@@ -1,10 +1,10 @@
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
const path = require('path');
const asyncPool = require('tiny-async-pool');
-const { parseDate } = require('@/utils/parse-date');
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import { parseDate } from '@/utils/parse-date';
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const rootUrl = 'https://www.bloomberg.com/feeds';
const idSel = 'script[id^="article-info"][type="application/json"], script[class^="article-info"][type="application/json"], script#dvz-config';
@@ -58,7 +58,7 @@ const emptyRegex = /
]*>( |\s)<\/p>/g;
const parseNewsList = async (url, ctx) => {
const resp = await got(url);
- const $ = cheerio.load(resp.data, {
+ const $ = load(resp.data, {
xml: {
xmlMode: true,
},
@@ -66,7 +66,7 @@ const parseNewsList = async (url, ctx) => {
const urls = $('urlset url');
return urls
.toArray()
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50)
.map((u) => {
u = $(u);
const item = {
@@ -137,7 +137,7 @@ const parseArticle = (item, ctx) =>
});
const parseAudioPage = async (res, api, item) => {
- const audio_json = JSON.parse(cheerio.load(res.data)(api.sel).html()).props.pageProps;
+ const audio_json = JSON.parse(load(res.data)(api.sel).html()).props.pageProps;
const episode = audio_json.episode;
const rss_item = {
title: episode.title || item.title,
@@ -158,7 +158,7 @@ const parseAudioPage = async (res, api, item) => {
};
const parseVideoPage = async (res, api, item) => {
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const script = $(api.sel).filter((i, el) => $(el).text().includes('__PRELOADED_STATE__'));
const json = script.text().trim().replace('window.__PRELOADED_STATE__ = ', '').slice(0, -1);
const article_json = JSON.parse(json);
@@ -183,7 +183,7 @@ const parseVideoPage = async (res, api, item) => {
};
const parsePhotoEssaysPage = async (res, api, item) => {
- const $ = cheerio.load(res.data.html);
+ const $ = load(res.data.html);
const article_json = $(api.sel)
.toArray()
.map((e) => JSON.parse($(e).html()))
@@ -200,7 +200,7 @@ const parsePhotoEssaysPage = async (res, api, item) => {
};
const parseReactRendererPage = async (res, api, item) => {
- const json = cheerio.load(res.data)(api.sel).text().trim();
+ const json = load(res.data)(api.sel).text().trim();
const story_id = JSON.parse(json)[api.prop];
try {
const res = await got(`${idUrl}${story_id}`, { headers });
@@ -292,7 +292,7 @@ const processLedeMedia = async (story_json) => {
const processBody = async (body_html, story_json) => {
const removeSel = ['meta', 'script', '*[class$="-footnotes"]', '*[class$="for-you"]', '*[class$="-newsletter"]', '*[class$="page-ad"]', '*[class$="-recirc"]', '*[data-ad-placeholder="Advertisement"]'];
- const $ = cheerio.load(body_html);
+ const $ = load(body_html);
for (const sel of removeSel) {
$(sel).remove();
}
diff --git a/lib/v2/bluestacks/release.js b/lib/v2/bluestacks/release.js
index 231b40254..a1b928dca 100644
--- a/lib/v2/bluestacks/release.js
+++ b/lib/v2/bluestacks/release.js
@@ -1,10 +1,11 @@
const cherrio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
+import puppeteer from '@/utils/puppeteer';
const pageUrl = 'https://support.bluestacks.com/hc/en-us/articles/360056960211-Release-Notes-BlueStacks-5';
module.exports = async (ctx) => {
- const browser = await require('@/utils/puppeteer')();
+ const browser = puppeteer();
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
@@ -53,11 +54,11 @@ module.exports = async (ctx) => {
await browser.close();
- ctx.state.data = {
+ ctx.set('data', {
title: $('.article__title').text().trim(),
description: $('meta[name=description]').text().trim(),
link: pageUrl,
image: $('link[rel="shortcut icon"]').attr('href'),
item: items,
- };
+ });
};
diff --git a/lib/v2/bmkg/earthquake.js b/lib/v2/bmkg/earthquake.js
index b1270cb4b..6d63ebe10 100644
--- a/lib/v2/bmkg/earthquake.js
+++ b/lib/v2/bmkg/earthquake.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const url = 'https://www.bmkg.go.id/gempabumi-terkini.html';
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('div .table-responsive tbody tr')
.toArray()
.map((item) => {
@@ -19,11 +19,11 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: url,
description: '印尼气象气候和地球物理局 最近的地震(M ≥ 5.0) | BMKG earthquake',
item: items,
language: 'in',
- };
+ });
};
diff --git a/lib/v2/bmkg/news.js b/lib/v2/bmkg/news.js
index 8d1e5b578..c769fbf09 100644
--- a/lib/v2/bmkg/news.js
+++ b/lib/v2/bmkg/news.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const url = 'https://www.bmkg.go.id';
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('div .ms-slide')
.toArray()
.map((item) => {
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const p = $('div .blog-grid').find('p');
item.description = p.text();
@@ -32,11 +32,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: url,
description: '印尼气象气候和地球物理局 新闻 | BMKG news',
item: items,
language: 'in',
- };
+ });
};
diff --git a/lib/v2/bnu/bs.js b/lib/v2/bnu/bs.js
index 324cdb601..697af9224 100644
--- a/lib/v2/bnu/bs.js
+++ b/lib/v2/bnu/bs.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'xw';
+ const category = ctx.req.param('category') ?? 'xw';
const rootUrl = 'http://bs.bnu.edu.cn';
const currentUrl = `${rootUrl}/${category}/index.html`;
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('a[title]')
.map((_, item) => {
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.right-c-content-con').html();
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('.right-c-title').text()} - ${$('title').text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bnu/dwxgb.js b/lib/v2/bnu/dwxgb.js
index 12d9c6793..794b836f5 100644
--- a/lib/v2/bnu/dwxgb.js
+++ b/lib/v2/bnu/dwxgb.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { category, type } = ctx.params;
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
}
}
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('ul.container.list > li')
.map((_, item) => {
@@ -37,16 +37,16 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('div.article.typo').html();
return item;
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('div.breadcrumb1 > a:nth-child(3)').text()} - ${$('div.breadcrumb1 > a:nth-child(4)').text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/bnu/fdy.js b/lib/v2/bnu/fdy.js
index b4319f537..1c8545e33 100644
--- a/lib/v2/bnu/fdy.js
+++ b/lib/v2/bnu/fdy.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'http://fdy.bnu.edu.cn';
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const link = `${baseUrl}/${path}/index.htm`;
const { data: response } = await got(link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = $('.listconrl li')
.toArray()
@@ -26,16 +26,16 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = $('.listconrc-newszw').html();
return item;
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/bnu/lib.js b/lib/v2/bnu/lib.js
index 0ef008ba9..40fac5647 100644
--- a/lib/v2/bnu/lib.js
+++ b/lib/v2/bnu/lib.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'http://www.lib.bnu.edu.cn';
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const link = `${baseUrl}/${category}/index.htm`;
const { data: response } = await got(link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = $('.view-content .item-list li')
.toArray()
@@ -25,16 +25,16 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = $('#block-system-main .content .content').html();
return item;
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/boc/whpj.js b/lib/v2/boc/whpj.js
index 8b768e4ce..abcbee61b 100644
--- a/lib/v2/boc/whpj.js
+++ b/lib/v2/boc/whpj.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const link = 'https://www.boc.cn/sourcedb/whpj/';
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
- const format = ctx.params.format;
+ const format = ctx.req.param('format');
const en_names = {
阿联酋迪拉姆: 'AED',
@@ -92,9 +92,9 @@ module.exports = async (ctx) => {
return info;
});
- ctx.state.data = {
+ ctx.set('data', {
title: '中国银行外汇牌价',
link,
item: out,
- };
+ });
};
diff --git a/lib/v2/bookfere/category.js b/lib/v2/bookfere/category.js
index 4d4eee176..cc1ab22c4 100644
--- a/lib/v2/bookfere/category.js
+++ b/lib/v2/bookfere/category.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const url = 'https://bookfere.com/category/' + ctx.params.category;
+ const url = 'https://bookfere.com/category/' + ctx.req.param('category');
const response = await got({
method: 'get',
url,
@@ -11,10 +11,10 @@ module.exports = async (ctx) => {
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('main div div section');
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: url,
item:
@@ -32,5 +32,5 @@ module.exports = async (ctx) => {
};
})
.get(),
- };
+ });
};
diff --git a/lib/v2/booru/mmda.js b/lib/v2/booru/mmda.js
index ef612df12..d4c5d5c34 100644
--- a/lib/v2/booru/mmda.js
+++ b/lib/v2/booru/mmda.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const queryString = require('query-string');
-const cheerio = require('cheerio');
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const baseUrl = 'https://mmda.booru.org';
- const tags = ctx.params.tags;
+ const tags = ctx.req.param('tags');
const query = queryString.stringify(
{
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
searchParams: query,
});
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = $('#post-list > div.content > div > div:nth-child(3) span')
.toArray()
.map((item) => {
@@ -39,9 +39,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: tags,
link: `${baseUrl}/index.php?${query}`,
item: list,
- };
+ });
};
diff --git a/lib/v2/bossdesign/index.js b/lib/v2/bossdesign/index.js
index e9edff22e..78c105479 100644
--- a/lib/v2/bossdesign/index.js
+++ b/lib/v2/bossdesign/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { category } = ctx.params;
- const limit = Number.parseInt(ctx.query.limit, 10) || undefined;
+ const limit = Number.parseInt(ctx.req.query('limit'), 10) || undefined;
const baseUrl = 'https://www.bossdesign.cn';
const currentCategory = await ctx.cache.tryGet(`bossdesign:categories:${category}`, async () => {
@@ -31,11 +31,11 @@ module.exports = async (ctx) => {
category: [...new Set([...item._embedded['wp:term'][0].map((item) => item.name), ...item._embedded['wp:term'][1].map((item) => item.name)])],
}));
- ctx.state.data = {
+ ctx.set('data', {
title: currentCategory?.name ? `${currentCategory.name} | Boss设计` : 'Boss设计 | 收集国外设计素材网站的资源平台。',
description: currentCategory?.description ?? 'Boss设计-收集国外设计素材网站的资源平台。专注于收集国外设计素材和国外设计网站,以及超实用的设计师神器,只为设计初学者和设计师提供海量的资源平台。..',
image: currentCategory?.cover ?? `${baseUrl}/wp-content/themes/pinghsu/images/Bossdesign-ico.ico`,
link: currentCategory?.link ?? baseUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/brave/latest.js b/lib/v2/brave/latest.js
index 8e33c6e56..5e1142176 100644
--- a/lib/v2/brave/latest.js
+++ b/lib/v2/brave/latest.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://brave.com';
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('.box h3')
.toArray()
@@ -32,9 +32,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/brooklynmuseum/exhibitions.js b/lib/v2/brooklynmuseum/exhibitions.js
index 2dfa5a9fd..9157a611a 100644
--- a/lib/v2/brooklynmuseum/exhibitions.js
+++ b/lib/v2/brooklynmuseum/exhibitions.js
@@ -2,7 +2,7 @@ const buildData = require('@/utils/common-config');
module.exports = async (ctx) => {
let link;
- const state = ctx.params.state;
+ const state = ctx.req.param('state');
switch (state) {
case undefined:
diff --git a/lib/v2/bse/index.js b/lib/v2/bse/index.js
index 00f8287d6..9ea4bb936 100644
--- a/lib/v2/bse/index.js
+++ b/lib/v2/bse/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const nodes = {
important_news: {
@@ -120,8 +120,8 @@ const nodes = {
};
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'important_news';
- const keyword = ctx.params.keyword ?? '';
+ const category = ctx.req.param('category') ?? 'important_news';
+ const keyword = ctx.req.param('keyword') ?? '';
const type = nodes[category].type;
const rootUrl = 'http://www.bse.cn';
@@ -132,7 +132,7 @@ module.exports = async (ctx) => {
url: currentUrl,
form: {
page: 0,
- pageSize: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50,
+ pageSize: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50,
keywords: keyword,
'nodeIds[]': type === '/info/listse' ? nodes[category].id : undefined,
disclosureSubtype: type === '/info/listse' ? undefined : nodes[category].id,
@@ -163,10 +163,10 @@ module.exports = async (ctx) => {
break;
}
- ctx.state.data = {
+ ctx.set('data', {
title: `${nodes[category].title} - 北京证券交易所`,
link: `${rootUrl}${nodes[category].url}`,
item: items,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/bsky/keyword.js b/lib/v2/bsky/keyword.js
index 4c7d53398..eae68528b 100644
--- a/lib/v2/bsky/keyword.js
+++ b/lib/v2/bsky/keyword.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
module.exports = async (ctx) => {
const { keyword } = ctx.params;
@@ -14,9 +14,9 @@ module.exports = async (ctx) => {
author: item.user.handle,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `Bluesky Keyword - ${keyword}`,
link: `https://bsky.app/search?q=${encodeURIComponent(keyword)}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/bsky/posts.js b/lib/v2/bsky/posts.js
index da774dc46..170a6e264 100644
--- a/lib/v2/bsky/posts.js
+++ b/lib/v2/bsky/posts.js
@@ -1,6 +1,6 @@
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
const { resolveHandle, getProfile, getAuthorFeed } = require('./utils');
-const { art } = require('@/utils/render');
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
comments: post.replyCount,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${profile.displayName} (@${profile.handle}) — Bluesky`,
description: profile.description?.replaceAll('\n', ' '),
link: `https://bsky.app/profile/${profile.handle}`,
@@ -32,11 +32,11 @@ module.exports = async (ctx) => {
icon: profile.avatar,
logo: profile.avatar,
item: items,
- };
+ });
- ctx.state.json = {
+ ctx.set('json', {
DID,
profile,
authorFeed,
- };
+ });
};
diff --git a/lib/v2/bsky/utils.js b/lib/v2/bsky/utils.js
index 09f5a9f6e..d2222f40c 100644
--- a/lib/v2/bsky/utils.js
+++ b/lib/v2/bsky/utils.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const config = require('@/config').value;
+import got from '@/utils/got';
+import { config } from '@/config';
/**
* docs: https://atproto.com/lexicons/app-bsky
diff --git a/lib/v2/btzj/index.js b/lib/v2/btzj/index.js
index 451f5b876..a7f431eb7 100644
--- a/lib/v2/btzj/index.js
+++ b/lib/v2/btzj/index.js
@@ -1,17 +1,17 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
-const config = require('@/config').value;
+import { config } from '@/config';
const allowDomain = new Set(['2btjia.com', '88btbtt.com', 'btbtt15.com', 'btbtt20.com']);
module.exports = async (ctx) => {
- let category = ctx.params.category ?? '';
- let domain = ctx.query.domain ?? 'btbtt15.com';
+ let category = ctx.req.param('category') ?? '';
+ let domain = ctx.req.query('domain') ?? 'btbtt15.com';
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.has(new URL(`http://${domain}/`).hostname)) {
- ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
+ throw new Error(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
if (category === 'base') {
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
$('.bg2').prevAll('table').remove();
@@ -53,7 +53,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('h2, .message').remove();
@@ -90,7 +90,7 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('#menu, #threadtype')
.find('.checked')
.toArray()
@@ -99,5 +99,5 @@ module.exports = async (ctx) => {
.join('|')} - BT之家`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/buaa/news/index.js b/lib/v2/buaa/news/index.js
index 0023e6971..6540e56d1 100644
--- a/lib/v2/buaa/news/index.js
+++ b/lib/v2/buaa/news/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const baseUrl = 'https://news.buaa.edu.cn';
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const { data: response, url: link } = await got(`${baseUrl}/${type}.htm`);
- const $ = cheerio.load(response);
+ const $ = load(response);
const title = $('.subnav span').text().trim();
const list = $('.mainleft > .listlefttop > .listleftop1')
.toArray()
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
item.description = $('.v_news_content').html();
item.author = $('.vsbcontent_end').text().trim();
@@ -37,10 +37,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `北航新闻 - ${title}`,
link,
description: `北京航空航天大学新闻网 - ${title}`,
item: result,
- };
+ });
};
diff --git a/lib/v2/buaa/sme.js b/lib/v2/buaa/sme.js
index 292961154..08bbebd39 100755
--- a/lib/v2/buaa/sme.js
+++ b/lib/v2/buaa/sme.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const BASE_URL = 'http://www.sme.buaa.edu.cn';
@@ -9,19 +9,19 @@ module.exports = async (ctx) => {
const { path = 'tzgg' } = ctx.params;
const url = `${BASE_URL}/${path}.htm`;
const { title, list } = await getList(url);
- ctx.state.data = {
+ ctx.set('data', {
// 源标题
title,
// 源链接
link: url,
// 源文章
item: await getItems(ctx, list),
- };
+ });
};
async function getList(url) {
const { data } = await got(url);
- const $ = cheerio.load(data);
+ const $ = load(data);
const title = $('.nytit .fr a')
.toArray()
.slice(1)
@@ -50,7 +50,7 @@ function getItems(ctx, list) {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: descrptionResponse } = await got(item.link);
- const $descrption = cheerio.load(descrptionResponse);
+ const $descrption = load(descrptionResponse);
item.description = $descrption('div[class="v_news_content"]').html();
return item;
})
diff --git a/lib/v2/bulianglin/bulianglin.js b/lib/v2/bulianglin/bulianglin.js
index e1107eea6..66a8994ff 100644
--- a/lib/v2/bulianglin/bulianglin.js
+++ b/lib/v2/bulianglin/bulianglin.js
@@ -1,11 +1,11 @@
-const { parseDate } = require('@/utils/parse-date');
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import { parseDate } from '@/utils/parse-date';
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const url = 'https://bulianglin.com/';
const response = await got({ method: 'get', url });
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('div.single-post')
.map((i, e) => {
@@ -24,9 +24,9 @@ module.exports = async (ctx) => {
})
.get();
- ctx.state.data = {
+ ctx.set('data', {
title: '不良林',
link: url,
item: list,
- };
+ });
};
diff --git a/lib/v2/bupt/rczp.js b/lib/v2/bupt/rczp.js
index 017115538..aea8cc39b 100644
--- a/lib/v2/bupt/rczp.js
+++ b/lib/v2/bupt/rczp.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://www.bupt.edu.cn';
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.date-block')
.map((_, item) => {
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.v_news_content').html();
item.pubDate = timezone(parseDate(content('.info span').first().text().replace('发布时间 : ', '')), +8);
@@ -43,9 +43,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/byteclicks/index.js b/lib/v2/byteclicks/index.js
index 7a91d614e..6f9b79515 100644
--- a/lib/v2/byteclicks/index.js
+++ b/lib/v2/byteclicks/index.js
@@ -1,22 +1,22 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const { parseItem } = require('./utils');
const baseUrl = 'https://byteclicks.com';
module.exports = async (ctx) => {
const { data } = await got(`${baseUrl}/wp-json/wp/v2/posts`, {
searchParams: {
- per_page: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 100,
+ per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100,
},
});
const items = parseItem(data);
- ctx.state.data = {
+ ctx.set('data', {
title: '字节点击 - 聚合全球优质资源,跟踪世界前沿科技',
description:
'byteclicks.com 最专业的前沿科技网站。聚合全球优质资源,跟踪世界前沿科技,精选推荐一些很棒的互联网好资源好工具好产品。寻找有前景好项目、找论文、找报告、找数据、找课程、找电子书上byteclicks!byteclicks.com是投资人、科研学者、学生每天必看的网站。',
image: 'https://byteclicks.com/wp-content/themes/RK-Blogger/images/wbolt.ico',
link: baseUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/byteclicks/tag.js b/lib/v2/byteclicks/tag.js
index 529237454..007b067f1 100644
--- a/lib/v2/byteclicks/tag.js
+++ b/lib/v2/byteclicks/tag.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const { parseItem } = require('./utils');
const baseUrl = 'https://byteclicks.com';
@@ -14,17 +14,17 @@ module.exports = async (ctx) => {
const { data } = await got(`${baseUrl}/wp-json/wp/v2/posts`, {
searchParams: {
- per_page: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 100,
+ per_page: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100,
tags: tagData.id,
},
});
const items = parseItem(data);
- ctx.state.data = {
+ ctx.set('data', {
title: `${tagData.name} - 字节点击`,
image: 'https://byteclicks.com/wp-content/themes/RK-Blogger/images/wbolt.ico',
link: tagData.link,
item: items,
- };
+ });
};
diff --git a/lib/v2/byteclicks/utils.js b/lib/v2/byteclicks/utils.js
index a728db20a..3cc92d954 100644
--- a/lib/v2/byteclicks/utils.js
+++ b/lib/v2/byteclicks/utils.js
@@ -1,4 +1,4 @@
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
const parseItem = (data) =>
data.map((item) => ({
diff --git a/lib/v2/bytes/bytes.js b/lib/v2/bytes/bytes.js
index a7464c396..4e016214a 100644
--- a/lib/v2/bytes/bytes.js
+++ b/lib/v2/bytes/bytes.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const currentURL = 'https://bytes.dev/archives';
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const resp = await got(currentURL);
- const $ = cheerio.load(resp.data);
+ const $ = load(resp.data);
const text = $('script#__NEXT_DATA__').text();
const json = JSON.parse(text);
const posts = [json.props.pageProps.featuredPost, ...json.props.pageProps.posts];
@@ -16,10 +16,10 @@ module.exports = async (ctx) => {
link: `/archives/${item.slug}`,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: 'bytes.dev',
description: 'Your weekly dose of JS',
link: currentURL,
item: items,
- };
+ });
};
diff --git a/lib/v2/c114/roll.js b/lib/v2/c114/roll.js
index feed8bedc..2d8fe2cf8 100644
--- a/lib/v2/c114/roll.js
+++ b/lib/v2/c114/roll.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
@@ -14,10 +14,10 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
+ const $ = load(iconv.decode(response.data, 'gbk'));
let items = $('.new_list_c h6 a')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50)
.toArray()
.map((item) => {
item = $(item);
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
+ const content = load(iconv.decode(detailResponse.data, 'gbk'));
item.description = content('.text').html();
item.author = content('.author').first().text().replace('C114通信网 ', '');
@@ -49,9 +49,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/caai/index.js b/lib/v2/caai/index.js
index 3d394a566..a5470a20c 100644
--- a/lib/v2/caai/index.js
+++ b/lib/v2/caai/index.js
@@ -1,22 +1,22 @@
const utils = require('./utils');
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const base = utils.urlBase(ctx.params.caty);
+ const base = utils.urlBase(ctx.req.param('caty'));
const res = await got(base);
const info = utils.fetchAllArticles(res.data);
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const details = await Promise.all(info.map((e) => utils.detailPage(e, ctx.cache)));
- ctx.state.json = {
+ ctx.set('json', {
info,
- };
+ });
- ctx.state.data = {
+ ctx.set('data', {
title: '中国人工智能学会 - ' + $('.article-list h1').text(),
link: base,
item: details,
- };
+ });
};
diff --git a/lib/v2/caai/utils.js b/lib/v2/caai/utils.js
index e7e79d754..8d3534f86 100644
--- a/lib/v2/caai/utils.js
+++ b/lib/v2/caai/utils.js
@@ -1,9 +1,9 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const base = 'http://www.caai.cn';
@@ -17,13 +17,13 @@ const renderDesc = (desc) =>
const detailPage = (e, cache) =>
cache.tryGet(e.link, async () => {
const result = await got(e.link);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
e.description = $('div.article').html();
return e;
});
const fetchAllArticles = (data) => {
- const $ = cheerio.load(data);
+ const $ = load(data);
const articles = $('div.article-list > ul > li');
const info = articles.toArray().map((e) => {
const c = $(e);
diff --git a/lib/v2/caam/index.js b/lib/v2/caam/index.js
index cd230b162..67d872450 100644
--- a/lib/v2/caam/index.js
+++ b/lib/v2/caam/index.js
@@ -1,17 +1,17 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { category = '1' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const rootUrl = 'http://www.caam.org.cn';
const currentUrl = new URL(`chn/1/cate_${category}/list_1.html`, rootUrl).href;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
let items = $('span.cont')
.slice(0, limit)
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
const infoEls = content('div.fourTop em');
@@ -51,7 +51,7 @@ module.exports = async (ctx) => {
const subtitle = $('div.topMeuns ul li a').last().text();
const image = new URL('images/header-back-7.png', rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `${author} - ${subtitle}`,
link: currentUrl,
@@ -60,5 +60,5 @@ module.exports = async (ctx) => {
image,
subtitle,
author,
- };
+ });
};
diff --git a/lib/v2/caareviews/book.js b/lib/v2/caareviews/book.js
index 50901a68d..34e6b711d 100644
--- a/lib/v2/caareviews/book.js
+++ b/lib/v2/caareviews/book.js
@@ -6,9 +6,9 @@ module.exports = async (ctx) => {
const list = await getList(url);
const items = await getItems(ctx, list);
- ctx.state.data = {
+ ctx.set('data', {
title: 'Book Reviews',
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/caareviews/essay.js b/lib/v2/caareviews/essay.js
index 67b3768a7..2960bc23f 100644
--- a/lib/v2/caareviews/essay.js
+++ b/lib/v2/caareviews/essay.js
@@ -6,9 +6,9 @@ module.exports = async (ctx) => {
const list = await getList(url);
const items = await getItems(ctx, list);
- ctx.state.data = {
+ ctx.set('data', {
title: 'Essays',
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/caareviews/exhibition.js b/lib/v2/caareviews/exhibition.js
index df9823a52..bbceaf2c8 100644
--- a/lib/v2/caareviews/exhibition.js
+++ b/lib/v2/caareviews/exhibition.js
@@ -6,9 +6,9 @@ module.exports = async (ctx) => {
const list = await getList(url);
const items = await getItems(ctx, list);
- ctx.state.data = {
+ ctx.set('data', {
title: 'Exhibition Reviews',
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/caareviews/utils.js b/lib/v2/caareviews/utils.js
index 23b544f58..6ee198e7d 100644
--- a/lib/v2/caareviews/utils.js
+++ b/lib/v2/caareviews/utils.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const rootUrl = 'http://www.caareviews.org';
const getList = async (url) => {
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('#infinite-content > div')
.map((_index, item) => ({
title: $(item).find('div.title').text().trim(),
@@ -25,7 +25,7 @@ const getItems = (ctx, list) =>
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const $ = cheerio.load(detailResponse.data);
+ const $ = load(detailResponse.data);
const coverUrl = new URL($('div.cover > a').attr('href'), rootUrl).href;
const content = $('div.content.full-review').html();
diff --git a/lib/v2/cahkms/index.js b/lib/v2/cahkms/index.js
index 6f3474876..5909287ae 100644
--- a/lib/v2/cahkms/index.js
+++ b/lib/v2/cahkms/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const titles = {
@@ -19,10 +19,10 @@ const titles = {
};
module.exports = async (ctx) => {
- const category = ctx.params.category ?? '03';
+ const category = ctx.req.param('category') ?? '03';
const rootUrl = 'http://www.cahkms.org';
- const currentUrl = `${rootUrl}/HKMAC/indexMac/getRightList?dm=${category}&page=1&countPage=${ctx.query.limit ?? 10}`;
+ const currentUrl = `${rootUrl}/HKMAC/indexMac/getRightList?dm=${category}&page=1&countPage=${ctx.req.query('limit') ?? 10}`;
const response = await got({
method: 'get',
@@ -61,9 +61,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${titles[category]} - 全国港澳研究会`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/caijing/roll.js b/lib/v2/caijing/roll.js
index 86e0e6f69..ed92f1ebb 100644
--- a/lib/v2/caijing/roll.js
+++ b/lib/v2/caijing/roll.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const baseUrl = 'https://roll.caijing.com.cn';
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
item.author = $('.editor').text().trim() || $('#editor_baidu').text().trim().replaceAll(/[()]/g, '');
item.description = $('.article-content').html();
item.category = [
@@ -37,10 +37,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '滚动新闻-财经网',
image: 'https://www.caijing.com.cn/favicon.ico',
link: response.url,
item: items,
- };
+ });
};
diff --git a/lib/v2/caixin/article.js b/lib/v2/caixin/article.js
index 1c9816f9d..4eb4d16f5 100644
--- a/lib/v2/caixin/article.js
+++ b/lib/v2/caixin/article.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const { parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -18,10 +18,10 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title: '财新网 - 首页',
link: 'https://www.caixin.com',
description: '财新网 - 首页',
item: items,
- };
+ });
};
diff --git a/lib/v2/caixin/blog.js b/lib/v2/caixin/blog.js
index 6be3d1191..1ebe775b9 100644
--- a/lib/v2/caixin/blog.js
+++ b/lib/v2/caixin/blog.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { isValidHost } = require('@/utils/valid-host');
-const { parseDate } = require('@/utils/parse-date');
+import { parseDate } from '@/utils/parse-date';
const { parseBlogArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
}
const link = `https://${column}.blog.caixin.com`;
const { data: response } = await got(link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const user = $('div.indexMainConri > script[type="text/javascript"]')
.text()
.substring('window.user = '.length + 1)
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
} = await got('https://blog.caixin.com/blog-api/post/posts', {
searchParams: {
page: 1,
- size: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 20,
+ size: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20,
content: '',
authorId,
sort: 'publishTime',
diff --git a/lib/v2/caixin/category.js b/lib/v2/caixin/category.js
index 2c5dfc538..cc3af053d 100644
--- a/lib/v2/caixin/category.js
+++ b/lib/v2/caixin/category.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { isValidHost } = require('@/utils/valid-host');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const { parseArticle } = require('./utils');
module.exports = async (ctx) => {
- const category = ctx.params.category;
- const column = ctx.params.column;
+ const category = ctx.req.param('category');
+ const column = ctx.req.param('column');
const url = `https://${column}.caixin.com/${category}`;
if (!isValidHost(column)) {
throw new Error('Invalid column');
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const title = $('head title').text();
const entity = JSON.parse(
$('script')
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
searchParams: {
subject: entity.id,
type: 0,
- count: ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25,
+ count: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 25,
picdim: '_266_177',
start: 0,
},
@@ -47,10 +47,10 @@ module.exports = async (ctx) => {
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
- ctx.state.data = {
+ ctx.set('data', {
title,
link: url,
description: '财新网 - 提供财经新闻及资讯服务',
item: items,
- };
+ });
};
diff --git a/lib/v2/caixin/database.js b/lib/v2/caixin/database.js
index ca83e69d7..bed20fc6c 100644
--- a/lib/v2/caixin/database.js
+++ b/lib/v2/caixin/database.js
@@ -1,8 +1,8 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
const currentUrl = `${rootUrl}/news/`;
const response = await got(currentUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('h4 a')
.toArray()
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.pubDate = timezone(parseDate(content('#pubtime_baidu').text()), +8);
item.description = art(path.join(__dirname, 'templates/article.art'), {
@@ -40,9 +40,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '财新数据通 - 专享资讯',
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/caixin/k.js b/lib/v2/caixin/k.js
index 3c4478f37..5bc3a6ba5 100644
--- a/lib/v2/caixin/k.js
+++ b/lib/v2/caixin/k.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const response = await got('https://k.caixin.com/app/v1/list', {
@@ -31,10 +31,10 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: '财新网 - 财新一线新闻',
link: 'https://k.caixin.com/web/',
description: '财新网 - 财新一线新闻',
item: items,
- };
+ });
};
diff --git a/lib/v2/caixin/latest.js b/lib/v2/caixin/latest.js
index a53383cce..c65425a0f 100644
--- a/lib/v2/caixin/latest.js
+++ b/lib/v2/caixin/latest.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(`caixin:latest:${item.link}`, async () => {
const entry_r = await got(item.link);
- const $ = cheerio.load(entry_r.data);
+ const $ = load(entry_r.data);
// desc
const desc = art(path.join(__dirname, 'templates/article.art'), {
@@ -37,9 +37,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '财新网 - 最新文章',
link: 'https://www.caixin.com/',
item: rss,
- };
+ });
};
diff --git a/lib/v2/caixin/utils.js b/lib/v2/caixin/utils.js
index 7ab99063e..992633354 100644
--- a/lib/v2/caixin/utils.js
+++ b/lib/v2/caixin/utils.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
const parseArticle = (item, tryGet) =>
@@ -9,7 +9,7 @@ const parseArticle = (item, tryGet) =>
: tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = art(path.join(__dirname, 'templates/article.art'), {
item,
@@ -28,7 +28,7 @@ const parseArticle = (item, tryGet) =>
const parseBlogArticle = (item, tryGet) =>
tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const article = $('#the_content').removeAttr('style');
article.find('img').removeAttr('style');
article
diff --git a/lib/v2/caixin/weekly.js b/lib/v2/caixin/weekly.js
index ad66261b4..4f310d635 100644
--- a/lib/v2/caixin/weekly.js
+++ b/lib/v2/caixin/weekly.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const link = 'https://weekly.caixin.com';
const { data: response } = await got(link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = [
...$('.mi')
@@ -19,13 +19,13 @@ module.exports = async (ctx) => {
.map((item) => ({
link: $(item).attr('href'),
})),
- ].slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 10);
+ ].slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 10);
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
- const $ = cheerio.load(data);
+ const $ = load(data);
item.title = $('head title')
.text()
@@ -49,12 +49,12 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title')
.text()
.replace(/_财新周刊频道_财新网$/, '')
.trim(),
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/caixinglobal/latest.js b/lib/v2/caixinglobal/latest.js
index 463b63078..1b7dea722 100644
--- a/lib/v2/caixinglobal/latest.js
+++ b/lib/v2/caixinglobal/latest.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { data } = await got('https://gateway.caixin.com/api/extapi/homeInterface.jsp', {
searchParams: {
subject: '100990318;100990314;100990311',
start: 0,
- count: ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 20,
+ count: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20,
type: '2',
_: Date.now(),
},
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
- const $ = cheerio.load(data);
+ const $ = load(data);
$('.loadingBox, .cons-pay-tip').remove();
let content = $('#appContent').prop('outerHTML');
@@ -54,11 +54,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: 'The Latest Top Headlines on China - Caixin Global',
description: 'The latest headlines on China finance, companies, politics, international affairs and other China-related issues from around the world. Caixin Global',
language: 'en',
link: 'https://www.caixinglobal.com/news/',
item: items,
- };
+ });
};
diff --git a/lib/v2/camchina/index.js b/lib/v2/camchina/index.js
index 431384131..2e49d40d8 100644
--- a/lib/v2/camchina/index.js
+++ b/lib/v2/camchina/index.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '1';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50;
+ const id = ctx.req.param('id') ?? '1';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const rootUrl = 'http://www.camchina.org.cn';
const currentUrl = `${rootUrl}/categories/${id}`;
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.M-main-l p a')
.slice(0, limit)
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.content').html();
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国管理现代化研究会 - ${$('.title_red').text()}`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cankaoxiaoxi/index.js b/lib/v2/cankaoxiaoxi/index.js
index ab8a52e29..9b616c5d3 100644
--- a/lib/v2/cankaoxiaoxi/index.js
+++ b/lib/v2/cankaoxiaoxi/index.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const id = ctx.params.id ?? 'diyi';
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 50;
+ const id = ctx.req.param('id') ?? 'diyi';
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;
const rootUrl = 'https://china.cankaoxiaoxi.com';
const listApiUrl = `${rootUrl}/json/channel/${id}/list.json`;
@@ -58,11 +58,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `参考消息 - ${channelResponse.data.name}`,
link: currentUrl,
description: '参考消息',
language: 'zh-cn',
item: items,
- };
+ });
};
diff --git a/lib/v2/cartoonmad/comic.js b/lib/v2/cartoonmad/comic.js
index c7b37a413..b99f69483 100644
--- a/lib/v2/cartoonmad/comic.js
+++ b/lib/v2/cartoonmad/comic.js
@@ -1,13 +1,13 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
+import { load } from 'cheerio';
+import got from '@/utils/got';
const iconv = require('iconv-lite');
-const { art } = require('@/utils/render');
+import { art } from '@/utils/render';
const path = require('path');
const baseUrl = 'https://www.cartoonmad.com';
const KEY = '5e585';
-const load = (id, { chapter, pages }) => {
+const loadContent = (id, { chapter, pages }) => {
let description = '';
for (let page = 1; page <= pages; page++) {
const url = `${baseUrl}/${KEY}/${id}/${chapter}/${String(page).padStart(3, '0')}.jpg`;
@@ -22,7 +22,7 @@ const getChapters = (id, list, tryGet) =>
Promise.all(
list.map((item) =>
tryGet(item.link, () => {
- item.description = load(id, item);
+ item.description = loadContent(id, item);
return item;
})
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
},
});
const content = iconv.decode(data, 'big5');
- const $ = cheerio.load(content);
+ const $ = load(content);
const bookIntro = $('#info').eq(0).find('td').text().trim();
// const coverImgSrc = $('.cover').parent().find('img').attr('src');
@@ -61,10 +61,10 @@ module.exports = async (ctx) => {
const chapters = await getChapters(id, list, ctx.cache.tryGet);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link,
description: bookIntro,
item: chapters,
- };
+ });
};
diff --git a/lib/v2/cas/cg/index.js b/lib/v2/cas/cg/index.js
index b29a147d7..4234bd4b3 100644
--- a/lib/v2/cas/cg/index.js
+++ b/lib/v2/cas/cg/index.js
@@ -1,19 +1,19 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
- ctx.params.caty = ctx.params.caty || 'zh';
+ const caty = ctx.req.param('caty') || 'zh';
const rootUrl = 'https://www.cas.cn';
- const currentUrl = `${rootUrl}/cg/${ctx.params.caty}/`;
+ const currentUrl = `${rootUrl}/cg/${caty}/`;
const response = await got({
method: 'get',
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('#content li')
.not('.gl_line')
.slice(0, 15)
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
const a = item.find('a');
return {
title: a.text(),
- link: `${rootUrl}/cg/${ctx.params.caty}${a.attr('href').replace('.', '')}`,
+ link: `${rootUrl}/cg/${caty}${a.attr('href').replace('.', '')}`,
};
})
.get();
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.TRS_Editor').html();
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), 8);
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text().replace('----', ' - '),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cas/genetics/index.js b/lib/v2/cas/genetics/index.js
index 577c16363..298fca270 100644
--- a/lib/v2/cas/genetics/index.js
+++ b/lib/v2/cas/genetics/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://genetics.cas.cn';
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
const currentUrl = `${baseUrl}/${path}/`;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
let items;
@@ -55,9 +55,9 @@ module.exports = async (ctx) => {
});
}
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cas/ia/yjs.js b/lib/v2/cas/ia/yjs.js
index 2c6215603..13a796cb2 100644
--- a/lib/v2/cas/ia/yjs.js
+++ b/lib/v2/cas/ia/yjs.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const link = 'http://www.ia.cas.cn/yjsjy/zs/sszs/';
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.col-md-9 li');
- ctx.state.data = {
+ ctx.set('data', {
title: '中科院自动化所',
link,
description: '中科院自动化所通知公告',
@@ -21,5 +21,5 @@ module.exports = async (ctx) => {
link: item.find('li a').attr('href'),
};
}),
- };
+ });
};
diff --git a/lib/v2/cas/iee/kydt.js b/lib/v2/cas/iee/kydt.js
index 230f54774..0070b6cc3 100644
--- a/lib/v2/cas/iee/kydt.js
+++ b/lib/v2/cas/iee/kydt.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const rootUrl = 'http://www.iee.cas.cn/xwzx/kydt/';
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
url: rootUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('li.entry .entry-content-title')
.slice(0, 15)
.toArray()
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('.article-content').html();
item.pubDate = timezone(parseDate(content('time').text().split(':')[1]), 8);
@@ -40,9 +40,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '科研成果 - 中国科学院电工研究所',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cas/is/index.js b/lib/v2/cas/is/index.js
index 8fb48c8c4..415050b59 100644
--- a/lib/v2/cas/is/index.js
+++ b/lib/v2/cas/is/index.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://is.cas.cn';
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const { path } = ctx.params;
const response = await got(`${baseUrl}/${path}/`);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const items = $('.list-news ul li')
.toArray()
.map((item) => {
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
}
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
item.description = $('.TRS_Editor').html();
return item;
@@ -36,9 +36,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: `${baseUrl}/${path}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/cas/mesalab/kb.js b/lib/v2/cas/mesalab/kb.js
index 68fa543ed..a11a2cc63 100644
--- a/lib/v2/cas/mesalab/kb.js
+++ b/lib/v2/cas/mesalab/kb.js
@@ -1,7 +1,7 @@
const cherrio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
const homepage = 'https://www.mesalab.cn';
@@ -32,10 +32,10 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: 'MESA 知识库',
description: '中国科学院信息工程研究所 第二研究室 处理架构组',
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/cas/sim/kyjz.js b/lib/v2/cas/sim/kyjz.js
index 891dd6689..58865e5c6 100644
--- a/lib/v2/cas/sim/kyjz.js
+++ b/lib/v2/cas/sim/kyjz.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const host = 'http://www.sim.cas.cn/';
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const link = new URL('xwzx2016/kyjz/', host).href;
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.list-news li')
.toArray()
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const author = $('.qtinfo.hidden-lg.hidden-md.hidden-sm').text();
const reg = /文章来源:(.*?)\|/g;
@@ -39,9 +39,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '中国科学院上海微系统与信息技术研究所 -- 科技进展',
link,
item: out,
- };
+ });
};
diff --git a/lib/v2/cast/index.js b/lib/v2/cast/index.js
index 3364eda20..998ff42ad 100644
--- a/lib/v2/cast/index.js
+++ b/lib/v2/cast/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const baseUrl = 'https://www.cast.org.cn';
module.exports = async (ctx) => {
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(response, {
+ const $ = load(response, {
xml: {
xmlMode: true,
},
@@ -35,14 +35,14 @@ module.exports = async (ctx) => {
const pageTitle = await ctx.cache.tryGet(link, async () => {
const { data: response } = await got(link);
- const $ = cheerio.load(response);
+ const $ = load(response);
return $('head title').text();
});
const list = $('record')
.toArray()
.map((item) => {
- item = cheerio.load($(item).html(), null, false);
+ item = load($(item).html(), null, false);
const a = item('a').first();
return {
title: a.text(),
@@ -55,7 +55,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = $('#zoom').html();
item.pubDate = timezone(parseDate($('meta[name=PubDate]').attr('content'), 'YYYY-MM-DD HH:mm'), +8);
@@ -65,10 +65,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: pageTitle,
link,
image: 'https://www.cast.org.cn/favicon.ico',
item: items,
- };
+ });
};
diff --git a/lib/v2/cau/ele.js b/lib/v2/cau/ele.js
index 8bc1e2645..d0dc5a441 100644
--- a/lib/v2/cau/ele.js
+++ b/lib/v2/cau/ele.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'https://ciee.cau.edu.cn';
@@ -17,10 +17,10 @@ module.exports = async (ctx) => {
permissiontype: 0,
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('recordset record');
- ctx.state.data = {
+ ctx.set('data', {
title: '中国农业大学信电学院',
link,
description: '中国农业大学信电学院通知公告',
@@ -38,5 +38,5 @@ module.exports = async (ctx) => {
guid: `${link}#${title}`,
};
}),
- };
+ });
};
diff --git a/lib/v2/cau/yjs.js b/lib/v2/cau/yjs.js
index 5e594602d..18eb11e3c 100644
--- a/lib/v2/cau/yjs.js
+++ b/lib/v2/cau/yjs.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const baseUrl = 'https://yz.cau.edu.cn';
@@ -17,10 +17,10 @@ module.exports = async (ctx) => {
permissiontype: 0,
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('recordset record');
- ctx.state.data = {
+ ctx.set('data', {
title: '中农研究生学院',
link,
description: '中农研究生学院',
@@ -38,5 +38,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.find('span').text().replaceAll(/[[\]]/g, '')),
};
}),
- };
+ });
};
diff --git a/lib/v2/caus/index.js b/lib/v2/caus/index.js
index f07ca0f0b..369d362c3 100644
--- a/lib/v2/caus/index.js
+++ b/lib/v2/caus/index.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const categories = {
0: {
@@ -28,7 +28,7 @@ const categories = {
};
module.exports = async (ctx) => {
- const category = ctx.params.category || '0';
+ const category = ctx.req.param('category') || '0';
const isHome = category === '0';
@@ -80,9 +80,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${categories[category].title} - 加美财经`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cbaigui/index.js b/lib/v2/cbaigui/index.js
index fb59ac917..f38a5b4db 100644
--- a/lib/v2/cbaigui/index.js
+++ b/lib/v2/cbaigui/index.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const { rootUrl, apiSlug, GetFilterId } = require('./utils');
module.exports = async (ctx) => {
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 50;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 50;
let filterName;
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
const items = response.slice(0, limit).map((item) => {
const terminologies = item._embedded['wp:term'];
- const content = cheerio.load(item.content?.rendered ?? item.content);
+ const content = load(item.content?.rendered ?? item.content);
// To handle lazy-loaded images from external sites.
@@ -81,11 +81,11 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- const $ = cheerio.load(currentResponse);
+ const $ = load(currentResponse);
const icon = $('link[rel="apple-touch-icon"]').first().prop('href');
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `纪妖${filterName ? ` - ${filterName}` : ''}`,
link: currentUrl,
@@ -96,5 +96,5 @@ module.exports = async (ctx) => {
logo: icon,
subtitle: $('p.site-description').text(),
author: $('p.site-title').text(),
- };
+ });
};
diff --git a/lib/v2/cbaigui/utils.js b/lib/v2/cbaigui/utils.js
index b12e1d413..a0b2fedc6 100644
--- a/lib/v2/cbaigui/utils.js
+++ b/lib/v2/cbaigui/utils.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const rootUrl = 'https://cbaigui.com';
const apiSlug = 'wp-json/wp/v2';
diff --git a/lib/v2/cbc/topics.js b/lib/v2/cbc/topics.js
index 73c2c0b3c..af892b455 100644
--- a/lib/v2/cbc/topics.js
+++ b/lib/v2/cbc/topics.js
@@ -1,16 +1,16 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const baseUrl = 'https://www.cbc.ca';
- const topic = ctx.params.topic || '';
+ const topic = ctx.req.param('topic') || '';
const url = `${baseUrl}/news${topic ? `/${topic.replace('-', '/')}` : ''}`;
const response = await got(url);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const links = [];
function pushLinks(index, item) {
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(link, async () => {
const result = await got(link);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
const head = JSON.parse($('script[type="application/ld+json"]').first().text());
if (!head) {
@@ -50,9 +50,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: url,
item: out.filter((x) => x.title),
- };
+ });
};
diff --git a/lib/v2/cbirc/index.js b/lib/v2/cbirc/index.js
index 4aa442e92..b7304f20f 100644
--- a/lib/v2/cbirc/index.js
+++ b/lib/v2/cbirc/index.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const categories = {
jgdt: {
@@ -78,7 +78,7 @@ async function getContent(item) {
}
module.exports = async (ctx) => {
- const category = ctx.params.category ?? 'ggtz';
+ const category = ctx.req.param('category') ?? 'ggtz';
const cat = categories[category];
// 请求集合
@@ -109,11 +109,11 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国银保监会-${cat.title}`,
link: cat.link,
description: `中国银保监会-${cat.title}`,
item: dataLs,
language: 'zh-CN',
- };
+ });
};
diff --git a/lib/v2/cbnweek/index.js b/lib/v2/cbnweek/index.js
index 6c35a1d5a..67200fe6e 100644
--- a/lib/v2/cbnweek/index.js
+++ b/lib/v2/cbnweek/index.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://www2021.cbnweek.com';
@@ -38,9 +38,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '第一财经杂志',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/ccac/news.js b/lib/v2/ccac/news.js
index 0b454f2d8..121ac8a10 100644
--- a/lib/v2/ccac/news.js
+++ b/lib/v2/ccac/news.js
@@ -1,12 +1,13 @@
const utils = require('./utils');
-const { parseDate } = require('@/utils/parse-date');
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import { parseDate } from '@/utils/parse-date';
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import puppeteer from '@/utils/puppeteer';
module.exports = async (ctx) => {
- const browser = await require('@/utils/puppeteer')();
- const lang = ctx.params.lang ?? 'sc';
- const type = utils.TYPE[ctx.params.type];
+ const browser = puppeteer();
+ const lang = ctx.req.param('lang') ?? 'sc';
+ const type = utils.TYPE[ctx.req.param('type')];
const BASE = utils.langBase(lang);
const page = await browser.newPage();
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const list = utils
.typeFilter(articles, type)
- .slice(0, ctx.query.limit ? Number(ctx.query.limit) : 30)
+ .slice(0, ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 30)
.map((item) => ({
title: item.name,
category: item.tags.map((tag) => tag.name),
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const $ = cheerio.load(detailResponse.data);
+ const $ = load(detailResponse.data);
$('.article_details_body > *').removeAttr('style');
item.description = $('.article_details_body').html();
return item;
@@ -46,11 +47,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `CCAC ${type}`,
link: BASE,
description: `CCAC ${type}`,
- language: ctx.params.lang ? utils.LANG_TYPE[ctx.params.lang] : utils.LANG_TYPE.sc,
+ language: ctx.req.param('lang') ? utils.LANG_TYPE[ctx.req.param('lang')] : utils.LANG_TYPE.sc,
item: items,
- };
+ });
};
diff --git a/lib/v2/ccf/ccfcv/index.js b/lib/v2/ccf/ccfcv/index.js
index 6a60130d1..81ad3e0f6 100644
--- a/lib/v2/ccf/ccfcv/index.js
+++ b/lib/v2/ccf/ccfcv/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const rootUrl = 'https://tc.ccf.org.cn';
@@ -15,12 +15,12 @@ const cateTitleMap = {
};
module.exports = async (ctx) => {
- const channel = ctx.params.channel;
- const cate = ctx.params.category;
+ const channel = ctx.req.param('channel');
+ const cate = ctx.req.param('category');
const url = `${rootUrl}/ccfcv/${channel}/${cate}/`;
const response = await got(url);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('div.article-item')
.toArray()
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
}
if (item.status !== 404) {
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
const pdfUrl = content('div.g-box1 p a').attr('href');
item.description = art(path.join(__dirname, '../templates/ccfcv/description.art'), {
pdfUrl,
@@ -60,9 +60,9 @@ module.exports = async (ctx) => {
);
}
- ctx.state.data = {
+ ctx.set('data', {
title: `计算机视觉专委 - ${cateTitleMap[channel][cate]}`,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/ccf/news.js b/lib/v2/ccf/news.js
index 2ba1bc2dd..9a191d903 100644
--- a/lib/v2/ccf/news.js
+++ b/lib/v2/ccf/news.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const category = ctx.params.category || 'Media_list';
+ const category = ctx.req.param('category') || 'Media_list';
const rootUrl = 'https://www.ccf.org.cn';
const currentUrl = `${rootUrl}/${category}/`;
const response = await got(currentUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.tit a')
.toArray()
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.new_info .num').remove();
@@ -37,9 +37,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/ccf/tfbd/index.js b/lib/v2/ccf/tfbd/index.js
index 6d488b67f..151fb7dce 100644
--- a/lib/v2/ccf/tfbd/index.js
+++ b/lib/v2/ccf/tfbd/index.js
@@ -1,22 +1,22 @@
const utils = require('./utils');
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
- const base = utils.urlBase(ctx.params.caty, ctx.params.id);
+ const base = utils.urlBase(ctx.req.param('caty'), ctx.req.param('id'));
const res = await got(base);
const info = utils.fetchAllArticles(res.data);
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const details = await Promise.all(info.map((e) => utils.detailPage(e, ctx.cache)));
- ctx.state.json = {
+ ctx.set('json', {
info,
- };
+ });
- ctx.state.data = {
+ ctx.set('data', {
title: '大数据专家委员会 - ' + $('.position a:last-child').text(),
link: base,
item: details,
- };
+ });
};
diff --git a/lib/v2/ccf/tfbd/utils.js b/lib/v2/ccf/tfbd/utils.js
index c24fead50..5a6ba9263 100644
--- a/lib/v2/ccf/tfbd/utils.js
+++ b/lib/v2/ccf/tfbd/utils.js
@@ -1,9 +1,9 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { art } from '@/utils/render';
const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const base = 'http://tfbd.ccf.org.cn';
@@ -17,14 +17,14 @@ const renderDesc = (desc) =>
const detailPage = (e, cache) =>
cache.tryGet(e.link, async () => {
const result = await got(e.link);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
e.description = $('div.articleCon').html();
return e;
});
const fetchAllArticles = (data) => {
- const $ = cheerio.load(data);
+ const $ = load(data);
const articles = $('div.file-list div.article-item');
const info = articles.toArray().map((e) => {
const c = $(e);
diff --git a/lib/v2/ccnu/career.js b/lib/v2/ccnu/career.js
index ebb8ba9cb..bde4a8040 100644
--- a/lib/v2/ccnu/career.js
+++ b/lib/v2/ccnu/career.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const host = 'https://ccnu.91wllm.com';
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.newsList');
const items =
@@ -23,9 +23,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: '华中师范大学就业信息',
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/ccnu/cs.js b/lib/v2/ccnu/cs.js
index db24020c6..a3db0b7af 100644
--- a/lib/v2/ccnu/cs.js
+++ b/lib/v2/ccnu/cs.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const link = 'http://cs.ccnu.edu.cn/xwzx/tzgg.htm';
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.list_box_07 li');
- ctx.state.data = {
+ ctx.set('data', {
title: '华中师范大学计算机学院',
link,
description: '华中师范大学计算机学院通知公告',
@@ -24,5 +24,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.find('.time').text(), 'DDYYYY-MM'),
};
}),
- };
+ });
};
diff --git a/lib/v2/ccnu/wu.js b/lib/v2/ccnu/wu.js
index a84491a5f..b7f71e315 100644
--- a/lib/v2/ccnu/wu.js
+++ b/lib/v2/ccnu/wu.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const link = 'http://uowji.ccnu.edu.cn/tzgg.htm';
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.zy-mainxrx li');
- ctx.state.data = {
+ ctx.set('data', {
title: '华中师范大学伍论贡学院',
link,
description: '华中师范大学伍论贡学院通知公告',
@@ -23,5 +23,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.find('small').text(), 'YYYY-MM-DD'),
};
}),
- };
+ });
};
diff --git a/lib/v2/ccnu/yjs.js b/lib/v2/ccnu/yjs.js
index 9062bebd2..20bc46093 100644
--- a/lib/v2/ccnu/yjs.js
+++ b/lib/v2/ccnu/yjs.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const link = 'http://gs.ccnu.edu.cn/zsgz/ssyjs.htm';
const response = await got(link);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.main-zyrx li');
- ctx.state.data = {
+ ctx.set('data', {
title: '华中师范大学研究生院',
link,
description: '华中师范大学研究生院通知公告',
@@ -23,5 +23,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.find('small').text(), 'YYYY-MM-DD'),
};
}),
- };
+ });
};
diff --git a/lib/v2/ccreports/index.js b/lib/v2/ccreports/index.js
index 36a374a64..3dd8e58c3 100644
--- a/lib/v2/ccreports/index.js
+++ b/lib/v2/ccreports/index.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const rootUrl = 'https://www.ccreports.com.cn';
module.exports = async (ctx) => {
const listData = await got.get(rootUrl);
- const $ = cheerio.load(listData.data);
+ const $ = load(listData.data);
const list = $('div.index-four-content > div.article-box')
.find('div.new-child')
.map((_, item) => ({
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailData = await got.get(item.link);
- const $ = cheerio.load(detailData.data);
+ const $ = load(detailData.data);
item.description = $('div.pdbox').html();
item.pubDate = timezone(parseDate($('div.newbox > div.newtit > p').text(), 'YYYY-MM-DD HH:mm:ss'), +8);
@@ -33,9 +33,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '消费者报道',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cctv/jx.js b/lib/v2/cctv/jx.js
index 965e6bad6..8670cbfe0 100644
--- a/lib/v2/cctv/jx.js
+++ b/lib/v2/cctv/jx.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = 'https://photo.cctv.com';
@@ -10,10 +10,10 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.textr a')
- .slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 10)
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10)
.map((_, item) => {
item = $(item);
return {
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
const date = content('head')
.html()
.match(/publishDate ="(.*) ";/)[1];
@@ -43,9 +43,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '央视网图片《镜象》',
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cctv/lm.js b/lib/v2/cctv/lm.js
index da644bd38..a7e888936 100644
--- a/lib/v2/cctv/lm.js
+++ b/lib/v2/cctv/lm.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? 'xwzk';
+ const id = ctx.req.param('id') ?? 'xwzk';
const rootUrl = 'https://tv.cctv.com';
const apiRootUrl = 'https://api.cntv.cn';
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(titleResponse.data);
+ const $ = load(titleResponse.data);
const topId = titleResponse.data.match(/(TOPC\d{16})/)[1];
const apiUrl = `${apiRootUrl}/NewVideo/getVideoListByColumn?id=${topId}&n=20&sort=desc&p=1&mode=0&serviceId=tvcctv`;
@@ -68,10 +68,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: currentUrl,
item: items,
description: $('meta[name=description]').attr('content'),
- };
+ });
};
diff --git a/lib/v2/cctv/utils/mzzlbg.js b/lib/v2/cctv/utils/mzzlbg.js
index 4c2019d50..a03f2087b 100644
--- a/lib/v2/cctv/utils/mzzlbg.js
+++ b/lib/v2/cctv/utils/mzzlbg.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async () => {
const url = 'https://api.cntv.cn/video/videolistById?serviceId=cbox&vsid=C10354&em=01&p=1&n=50';
diff --git a/lib/v2/cctv/utils/news.js b/lib/v2/cctv/utils/news.js
index 3278a76a9..7a6a15d99 100644
--- a/lib/v2/cctv/utils/news.js
+++ b/lib/v2/cctv/utils/news.js
@@ -1,8 +1,10 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
-const UA = require('@/utils/rand-user-agent')({ browser: 'mobile safari', os: 'ios', device: 'mobile' });
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
+import randUserAgent from '@/utils/rand-user-agent';
+
+const UA = randUserAgent({ browser: 'mobile safari', os: 'ios', device: 'mobile' });
module.exports = async (category, ctx) => {
const url = `https://news.cctv.com/2019/07/gaiban/cmsdatainterface/page/${category}_1.jsonp`;
diff --git a/lib/v2/cctv/utils/xinwen1j1.js b/lib/v2/cctv/utils/xinwen1j1.js
index 0cffdfe10..e954506d4 100644
--- a/lib/v2/cctv/utils/xinwen1j1.js
+++ b/lib/v2/cctv/utils/xinwen1j1.js
@@ -1,13 +1,13 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
//
// 测试http://localhost:1200/cctv/xinwen1j1
// 完整文章页
-async function load(link) {
+async function loadContent(link) {
const res = await got({ method: 'get', url: link });
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
// console.log($('div.image').get().text())
// console.log('********')
const js_txt = '' + $('script');
@@ -46,7 +46,7 @@ const ProcessFeed = (data, ctx) =>
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
- const other = await ctx.cache.tryGet(itemUrl, () => load(itemUrl));
+ const other = await ctx.cache.tryGet(itemUrl, () => loadContent(itemUrl));
// 合并解析后的结果集作为该篇文章最终的输出结果
return { ...single, ...other };
diff --git a/lib/v2/cctv/xwlb.js b/lib/v2/cctv/xwlb.js
index abf214d9e..54309185b 100644
--- a/lib/v2/cctv/xwlb.js
+++ b/lib/v2/cctv/xwlb.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
+import { load } from 'cheerio';
const dayjs = require('dayjs');
const customParseFormat = require('dayjs/plugin/customParseFormat');
dayjs.extend(customParseFormat);
module.exports = async (ctx) => {
const res = await got({ method: 'get', url: 'https://tv.cctv.com/lm/xwlb/' });
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
// 解析最新一期新闻联播的日期
const latestDate = dayjs($('.rilititle p').text(), 'YYYY-MM-DD');
const count = [];
@@ -25,8 +25,8 @@ module.exports = async (ctx) => {
pubDate: timezone(parseDate(newsDate), +8),
description: await ctx.cache.tryGet(url, async () => {
const res = await got(url);
- const content = cheerio.load(res.data);
- const list = new Array();
+ const content = load(res.data);
+ const list = [];
content('body li').map((i, e) => {
e = content(e);
const href = e.find('a').attr('href');
@@ -42,9 +42,9 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: 'CCTV 新闻联播',
link: 'http://tv.cctv.com/lm/xwlb/',
item: resultItems,
- };
+ });
};
diff --git a/lib/v2/cde/index.js b/lib/v2/cde/index.js
index 65a2b64c8..080b0f26c 100644
--- a/lib/v2/cde/index.js
+++ b/lib/v2/cde/index.js
@@ -1,7 +1,7 @@
const utils = require('./utils');
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const channelLinkMap = {
news: 'https://www.cde.org.cn/main/news/listpage/545cf855a50574699b46b26bcb165f32',
@@ -75,9 +75,9 @@ const requestData = {
};
module.exports = async (ctx) => {
- const channel = ctx.params.channel;
- const cate = ctx.params.category;
- requestData[channel][cate].pageSize = ctx.params.limit ?? 25;
+ const channel = ctx.req.param('channel');
+ const cate = ctx.req.param('category');
+ requestData[channel][cate].pageSize = ctx.req.param('limit') ?? 25;
const url = `${utils.rootUrl}/main/${channel}/${cateUrlMap[channel][cate]}`;
const response = await got({
@@ -109,7 +109,7 @@ module.exports = async (ctx) => {
cookie: await utils.getCookie(ctx),
},
});
- const $ = cheerio.load(detailResponse.data);
+ const $ = load(detailResponse.data);
item.pubDate = parseDate($('div.news_detail_date').text(), 'YYYYMMDD');
@@ -124,9 +124,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${utils.title} - ${cateTitleMap[channel][cate]}`,
link: channelLinkMap[channel],
item: items,
- };
+ });
};
diff --git a/lib/v2/cde/utils.js b/lib/v2/cde/utils.js
index 88c66379d..5271c0378 100644
--- a/lib/v2/cde/utils.js
+++ b/lib/v2/cde/utils.js
@@ -1,4 +1,4 @@
-const got = require('@/utils/got');
+import got from '@/utils/got';
const title = '国家药品监督管理局药品审评中心';
const rootUrl = 'https://www.cde.org.cn';
diff --git a/lib/v2/cde/xxgk.js b/lib/v2/cde/xxgk.js
index 6c2ac71d1..8b9bbda65 100644
--- a/lib/v2/cde/xxgk.js
+++ b/lib/v2/cde/xxgk.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const utils = require('./utils');
@@ -65,9 +65,9 @@ module.exports = async (ctx) => {
link: xxgkMap.xxgk[category].url,
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `${xxgkMap.xxgk[category].title} - 国家药品监督管理局药品审评中心`,
link: xxgkMap.xxgk[category].url,
item: items,
- };
+ });
};
diff --git a/lib/v2/cde/zdyz.js b/lib/v2/cde/zdyz.js
index 3cd7bb499..fbc5ef856 100644
--- a/lib/v2/cde/zdyz.js
+++ b/lib/v2/cde/zdyz.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const utils = require('./utils');
const baseUrl = 'https://www.cde.org.cn';
@@ -62,16 +62,16 @@ module.exports = async (ctx) => {
cookie: await utils.getCookie(ctx),
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
item.description = $('.new_detail_content').html() + $('.relatedNews').html();
return item;
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${zdyzMap.zdyz[category].title} - 国家药品监督管理局药品审评中心`,
link: zdyzMap.zdyz[category].url,
item: items,
- };
+ });
};
diff --git a/lib/v2/cdi/index.js b/lib/v2/cdi/index.js
index 7cd310d42..30d4841f7 100644
--- a/lib/v2/cdi/index.js
+++ b/lib/v2/cdi/index.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '152';
+ const id = ctx.req.param('id') ?? '152';
const rootUrl = 'http://www.cdi.com.cn';
const currentUrl = `${rootUrl}/Article/List?ColumnId=${id}`;
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.a-full')
.toArray()
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.title = content('h1').text();
item.description = content('#info').html();
@@ -53,9 +53,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('h1').text()} - 国家高端智库/综合开发研究院`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cdzjryb/project-list.js b/lib/v2/cdzjryb/project-list.js
index 58c283875..993979a65 100644
--- a/lib/v2/cdzjryb/project-list.js
+++ b/lib/v2/cdzjryb/project-list.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
const url = 'https://zw.cdzjryb.com/lottery/accept/projectList';
const { data: response } = await got(url);
- const $ = cheerio.load(response);
+ const $ = load(response);
const list = $('#_projectInfo tr')
.toArray()
@@ -41,9 +41,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/cebbank/all.js b/lib/v2/cebbank/all.js
index 9c5821ea4..492cf8f8e 100644
--- a/lib/v2/cebbank/all.js
+++ b/lib/v2/cebbank/all.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const path = require('path');
-const { art } = require('@/utils/render');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const md5 = require('@/utils/md5');
+import { art } from '@/utils/render';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import md5 from '@/utils/md5';
module.exports = async (ctx) => {
const link = 'https://www.cebbank.com/eportal/ui?pageId=477257';
@@ -13,14 +13,14 @@ module.exports = async (ctx) => {
url: link,
});
- const $ = cheerio.load(content.data);
+ const $ = load(content.data);
const items = $('.lczj_box tbody tr')
.map((i, e) => {
if (i < 2) {
return null;
}
- const c = cheerio.load(e, { decodeEntities: false });
+ const c = load(e, { decodeEntities: false });
return {
title: c('td:nth-child(1)').text(),
description: art(path.join(__dirname, 'templates/allDes.art'), {
@@ -35,17 +35,17 @@ module.exports = async (ctx) => {
})
.get();
- ctx.state.data = {
+ ctx.set('data', {
title: '中国光大银行',
description: '中国光大银行 外汇牌价',
link,
item: items,
- };
+ });
- ctx.state.json = {
+ ctx.set('json', {
title: '中国光大银行',
description: '中国光大银行 外汇牌价',
pubDate: timezone(parseDate($('#t_id span').text().substring(5), 'YYYY-MM-DD HH:mm', true), 0),
item: items,
- };
+ });
};
diff --git a/lib/v2/cebbank/history.js b/lib/v2/cebbank/history.js
index 98a460825..f5293de48 100644
--- a/lib/v2/cebbank/history.js
+++ b/lib/v2/cebbank/history.js
@@ -1,27 +1,27 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const path = require('path');
-const { art } = require('@/utils/render');
+import { art } from '@/utils/render';
const utils = require('./utils');
const { TYPE } = utils;
module.exports = async (ctx) => {
- const type = ctx.params.type;
+ const type = ctx.req.param('type');
const url = `https://www.cebbank.com/eportal/ui?struts.portlet.action=/portlet/whpjFront!toView.action&moduleId=12094&pageId=477260&currcode=${TYPE[type].id}¤tPagebak=1¤tPage=1`;
const res = await got({
method: 'get',
url,
});
- const $ = cheerio.load(res.data);
+ const $ = load(res.data);
const items = $('.lczj_box tbody tr')
.map((i, e) => {
if (i < 2) {
return null;
}
- const c = cheerio.load(e, { decodeEntities: false });
+ const c = load(e, { decodeEntities: false });
return {
title: c('td:nth-child(1)').text(),
description: art(path.join(__dirname, 'templates/historyDes.art'), {
@@ -35,16 +35,16 @@ module.exports = async (ctx) => {
})
.get();
items.pop();
- ctx.state.data = {
+ ctx.set('data', {
title: '中国光大银行',
description: `中国光大银行 外汇牌价 ${TYPE[type].name}`,
link: `https://www.cebbank.com/site/ygzx/whpj/rmbwhpjlspj/index.html?currcode=${TYPE[type].id}`,
item: items,
- };
+ });
- ctx.state.json = {
+ ctx.set('json', {
title: '中国光大银行',
description: `中国光大银行 外汇牌价 ${TYPE[type].name}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/cfachina/analygarden.js b/lib/v2/cfachina/analygarden.js
index 5f171ba13..8f990eb7e 100644
--- a/lib/v2/cfachina/analygarden.js
+++ b/lib/v2/cfachina/analygarden.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
let { program = '分析师园地' } = ctx.params;
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
pageUrl = `${pageUrl}${program}/`;
const response = await got(pageUrl);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
program = $('script:contains("Paging")')
.text()
.match(/var name = '(.+)';/)[1];
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
},
searchParams: {
pageNo: 1,
- pageSize: ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 20,
+ pageSize: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20,
keyword: '',
startTime: '',
endTime: '',
@@ -52,9 +52,9 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: `${pageData?.category.toReversed().join(' - ') ?? '分析师园地'} - 中国期货业协会`,
link: pageUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/cfmmc/index.js b/lib/v2/cfmmc/index.js
index 107dcfcf2..1df20e32b 100644
--- a/lib/v2/cfmmc/index.js
+++ b/lib/v2/cfmmc/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { id = 'main/noticeannouncement/cfmmcnotice' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 10;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 10;
const rootUrl = 'http://www.cfmmc.com';
const apiUrl = new URL('servlet/json', rootUrl).href;
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- const $ = cheerio.load(currentResponse);
+ const $ = load(currentResponse);
const catalogId = $('#catalogId').prop('value');
@@ -45,7 +45,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
item.title = content('div.article_title h2').text();
item.description = content('div.cont_txt').html();
@@ -58,7 +58,7 @@ module.exports = async (ctx) => {
const author = '中国期货市场监控中心';
const image = new URL($('a.logo img').prop('src'), rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `${author} - ${$('h3.SubPage_t3').text()}`,
link: currentUrl,
@@ -68,5 +68,5 @@ module.exports = async (ctx) => {
subtitle: $('meta[name="Keywords"]').prop('content'),
author,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/cgtn/podcast.js b/lib/v2/cgtn/podcast.js
index b7de95941..c679347e3 100644
--- a/lib/v2/cgtn/podcast.js
+++ b/lib/v2/cgtn/podcast.js
@@ -1,6 +1,6 @@
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
async function getData(category, id) {
const url = `https://radio.cgtn.com/downapiRES/radio/v1/program/historyList/programId${id}_category${category}_page1.json`;
@@ -26,10 +26,10 @@ module.exports = async (ctx) => {
enclosure_url: item.mediaUrl,
enclosure_type: 'audio/mpeg',
}));
- ctx.state.data = {
+ ctx.set('data', {
title: `中国环球电视网 CGTN Podcast - ${data.info}`,
link: 'https://www.cgtn.com/radio/',
item: items,
description: String(data.info),
- };
+ });
};
diff --git a/lib/v2/chaincatcher/home.js b/lib/v2/chaincatcher/home.js
index 47c363866..9c24d12fa 100644
--- a/lib/v2/chaincatcher/home.js
+++ b/lib/v2/chaincatcher/home.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const rootUrl = 'https://www.chaincatcher.com';
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
if (item.categoryId !== 3) {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
item.description = art(path.join(__dirname, 'templates/home.art'), {
summary: item.description,
article: $('.article-container').html(),
@@ -40,11 +40,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '链捕手ChainCatcher — 专业的区块链技术研究与资讯平台-Chain Catcher',
description: '链捕手ChainCatcher为区块链技术爱好者与项目决策者提供NFT、Web3社交、DID、Layer2等专业的资讯与研究内容,Chain Catcher输出对Scroll、Sui、Aptos、ENS等项目的思考,拓宽读者对区块链与数字经济认知的边界。',
image: `${rootUrl}/logo.png`,
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/chaincatcher/news.js b/lib/v2/chaincatcher/news.js
index ce26a243d..9ac86ef9c 100644
--- a/lib/v2/chaincatcher/news.js
+++ b/lib/v2/chaincatcher/news.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const rootUrl = 'https://www.chaincatcher.com';
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
},
});
- const $ = cheerio.load(data.data, null, false);
+ const $ = load(data.data, null, false);
$('.share').remove();
const items = $('.block')
@@ -30,11 +30,11 @@ module.exports = async (ctx) => {
};
});
- ctx.state.data = {
+ ctx.set('data', {
title: '最新资讯-ChainCatcher',
description: '链捕手ChainCatcher为区块链技术爱好者与项目决策者提供NFT、Web3社交、DID、Layer2等专业的资讯与研究内容,Chain Catcher输出对Scroll、Sui、Aptos、ENS等项目的思考,拓宽读者对区块链与数字经济认知的边界。',
image: `${rootUrl}/logo.png`,
link: `${rootUrl}/news`,
item: items,
- };
+ });
};
diff --git a/lib/v2/changba/user.js b/lib/v2/changba/user.js
index 597596bc1..d115f94a6 100644
--- a/lib/v2/changba/user.js
+++ b/lib/v2/changba/user.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { art } from '@/utils/render';
const path = require('path');
const headers = { 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1' };
module.exports = async (ctx) => {
- const userid = ctx.params.userid;
+ const userid = ctx.req.param('userid');
const url = `https://changba.com/wap/index.php?s=${userid}`;
const response = await got({
method: 'get',
@@ -13,14 +13,14 @@ module.exports = async (ctx) => {
headers,
});
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const list = $('.user-work .work-info').get();
const author = $('div.user-main-info > span.txt-info > a.uname').text();
const authorimg = $('div.user-main-info > .poster > img').attr('data-src');
let items = await Promise.all(
list.map(async (item) => {
- const $ = cheerio.load(item);
+ const $ = load(item);
const link = $('a').attr('href');
const songid = await ctx.cache.tryGet(
link,
@@ -72,7 +72,7 @@ module.exports = async (ctx) => {
items = items.filter(Boolean);
- ctx.state.data = {
+ ctx.set('data', {
title: $('title').text(),
link: url,
description: $('meta[name="description"]').attr('content') || $('title').text(),
@@ -80,5 +80,5 @@ module.exports = async (ctx) => {
image: authorimg,
itunes_author: author,
itunes_category: '唱吧',
- };
+ });
};
diff --git a/lib/v2/chaoxing/qk.js b/lib/v2/chaoxing/qk.js
index 3d561d3ed..bbe0b2941 100644
--- a/lib/v2/chaoxing/qk.js
+++ b/lib/v2/chaoxing/qk.js
@@ -1,15 +1,15 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const id = ctx.params.id;
- const needContent = /t|y/i.test(ctx.params.needContent ?? 'true');
+ const id = ctx.req.param('id');
+ const needContent = /t|y/i.test(ctx.req.param('needContent') ?? 'true');
const rootUrl = 'http://m.chaoxing.com';
- const currentUrl = `${rootUrl}/mqk/json?size=${ctx.query.limit ?? 30}&mags=${id}&isort=20`;
+ const currentUrl = `${rootUrl}/mqk/json?size=${ctx.req.query('limit') ?? 30}&mags=${id}&isort=20`;
const headers = {
cookie: 'duxiu=userName_dsr%2C%3Dmmxy%2C!userid_dsr%2C%3D837%2C!enc_dsr%2C%3D7EDE234634FC80D554A7F6D1AA0D3629; AID_dsr=665; msign_dsr=1638170006420;',
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
headers,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.description = content('#article_content').html() ?? content('body').html();
}
@@ -51,9 +51,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: response.data.list[0].infos.C307,
link: `${rootUrl}/mqk/list?mags=${id}&isort=20&from=space`,
item: items,
- };
+ });
};
diff --git a/lib/v2/chaping/banner.js b/lib/v2/chaping/banner.js
index f57ada63d..1c3a741a9 100644
--- a/lib/v2/chaping/banner.js
+++ b/lib/v2/chaping/banner.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const rootUrl = `https://chaping.cn/`;
@@ -32,9 +32,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '差评 - 首页图片墙',
link: rootUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/chaping/news.js b/lib/v2/chaping/news.js
index a412196bb..c1e6365d2 100644
--- a/lib/v2/chaping/news.js
+++ b/lib/v2/chaping/news.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const titles = {
0: '全部',
@@ -14,10 +14,10 @@ const titles = {
};
module.exports = async (ctx) => {
- ctx.params.caty = ctx.params.caty ?? '';
+ const caty = ctx.req.param('caty') ?? '';
- const targetUrl = `https://chaping.cn/news?cate=${ctx.params.caty}`;
- const currentUrl = `https://chaping.cn/api/official/information/news?page=1&limit=16&cate=${ctx.params.caty}`;
+ const targetUrl = `https://chaping.cn/news?cate=${caty}`;
+ const currentUrl = `https://chaping.cn/api/official/information/news?page=1&limit=16&cate=${caty}`;
const apiResponse = await got({
method: 'get',
url: currentUrl,
@@ -45,11 +45,9 @@ module.exports = async (ctx) => {
)
);
- ctx.params.caty = ctx.params.caty === '' ? 0 : ctx.params.caty;
-
- ctx.state.data = {
- title: `差评资讯 - ${titles[ctx.params.caty]}`,
+ ctx.set('data', {
+ title: `差评资讯 - ${titles[ctx.req.param('caty') === '' ? 0 : ctx.req.param('caty')]}`,
link: targetUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/chaping/newsflash.js b/lib/v2/chaping/newsflash.js
index bd33c367d..41b6068fe 100644
--- a/lib/v2/chaping/newsflash.js
+++ b/lib/v2/chaping/newsflash.js
@@ -1,5 +1,5 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const host = 'https://chaping.cn';
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
const response = await got(newflashAPI).json();
const data = response.data;
- ctx.state.data = {
+ ctx.set('data', {
title: '差评 快讯',
link: `${host}/newsflash`,
item:
@@ -19,5 +19,5 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.time_publish_timestamp * 1000),
link: item.origin_url,
})),
- };
+ });
};
diff --git a/lib/v2/chiculture/topic.js b/lib/v2/chiculture/topic.js
index d83ace4ba..949a07fec 100644
--- a/lib/v2/chiculture/topic.js
+++ b/lib/v2/chiculture/topic.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
- const category = ctx.params.category || '';
+ const category = ctx.req.param('category') || '';
const rootUrl = 'https://ls.chiculture.org.hk';
const currentUrl = `${rootUrl}/api/general-listing?lang=zh-hant&type=ssrh&category=${category}&page=1`;
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
const pubDate = detailResponse.data.match(/上載日期:(.*)<\/p>/);
@@ -53,9 +53,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '議題熱話 | 通識·現代中國',
link: `${rootUrl}/tc/hot-topics${category ? `?category=${category}` : ''}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/china/finance/finance.js b/lib/v2/china/finance/finance.js
index a0b6b272c..821c57614 100644
--- a/lib/v2/china/finance/finance.js
+++ b/lib/v2/china/finance/finance.js
@@ -1,7 +1,7 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const CATEGORY_MAP = {
tuijian: 'tuijian', // 推荐
@@ -16,14 +16,14 @@ const CATEGORY_MAP = {
module.exports = async (ctx) => {
const baseUrl = 'https://finance.china.com';
- const category = CATEGORY_MAP[ctx.params.category] ?? CATEGORY_MAP.tuijian;
+ const category = CATEGORY_MAP[ctx.req.param('category')] ?? CATEGORY_MAP.tuijian;
const websiteUrl = `${baseUrl}/${category}`;
const response = await got(websiteUrl);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const categoryTitle = $('.list-hd strong').text();
const listCategory = `中华网-财经-${categoryTitle}新闻`;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
const detailsUrls = $('.item-con-inner')
.map((_, item) => {
item = $(item);
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
detailsUrls.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailsResponse = await got(item.link);
- const $d = cheerio.load(detailsResponse.data);
+ const $d = load(detailsResponse.data);
return {
title: $d('.article_title').text(),
link: item.link,
@@ -52,10 +52,10 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: websiteUrl,
category: listCategory,
item: items,
- };
+ });
};
diff --git a/lib/v2/china/news/highlights/news.js b/lib/v2/china/news/highlights/news.js
index 9ef6f95a5..ffaf9450e 100644
--- a/lib/v2/china/news/highlights/news.js
+++ b/lib/v2/china/news/highlights/news.js
@@ -1,6 +1,6 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
const CATEGORY_MAP = {
domestic: 'domestic',
@@ -11,14 +11,14 @@ const CATEGORY_MAP = {
module.exports = async (ctx) => {
const baseUrl = 'https://news.china.com';
- const category = CATEGORY_MAP[ctx.params.category] ?? CATEGORY_MAP.domestic;
+ const category = CATEGORY_MAP[ctx.req.param('category')] ?? CATEGORY_MAP.domestic;
const websiteUrl = `${baseUrl}/${category}`;
const response = await got(websiteUrl);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const categoryTitle = $('.wp_title').text();
const news = $('.item_list li');
- ctx.state.data = {
+ ctx.set('data', {
title: `中华网-${categoryTitle}新闻`,
link: websiteUrl,
item:
@@ -36,5 +36,5 @@ module.exports = async (ctx) => {
};
})
.get(),
- };
+ });
};
diff --git a/lib/v2/china/news/military/news.js b/lib/v2/china/news/military/news.js
index 28373fbc5..904a3272d 100644
--- a/lib/v2/china/news/military/news.js
+++ b/lib/v2/china/news/military/news.js
@@ -1,14 +1,14 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const websiteUrl = 'https://military.china.com/news/';
const response = await got(websiteUrl);
const data = response.data;
- const $ = cheerio.load(data);
+ const $ = load(data);
const commonList = $('.item_list li');
- ctx.state.data = {
+ ctx.set('data', {
title: '中华网-军事新闻',
link: 'https://military.china.com/news/',
item:
@@ -26,5 +26,5 @@ module.exports = async (ctx) => {
};
})
.get(),
- };
+ });
};
diff --git a/lib/v2/chinadegrees/province.js b/lib/v2/chinadegrees/province.js
index 3c8e2de82..194b7d565 100644
--- a/lib/v2/chinadegrees/province.js
+++ b/lib/v2/chinadegrees/province.js
@@ -1,8 +1,9 @@
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
-const config = require('@/config').value;
+import { config } from '@/config';
+import puppeteer from '@/utils/puppeteer';
const baseUrl = 'http://www.chinadegrees.com.cn';
module.exports = async (ctx) => {
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const data = await ctx.cache.tryGet(
url,
async () => {
- const browser = await require('@/utils/puppeteer')();
+ const browser = puppeteer();
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const html = await page.evaluate(() => document.documentElement.innerHTML);
await browser.close();
- const $ = cheerio.load(html);
+ const $ = load(html);
return {
title: $('caption').text().trim(),
items: $('.datalist tr')
@@ -58,9 +59,9 @@ module.exports = async (ctx) => {
return item;
});
- ctx.state.data = {
+ ctx.set('data', {
title: data.title,
link: url,
item: items,
- };
+ });
};
diff --git a/lib/v2/chinafactcheck/index.js b/lib/v2/chinafactcheck/index.js
index 0483edf2e..396703869 100644
--- a/lib/v2/chinafactcheck/index.js
+++ b/lib/v2/chinafactcheck/index.js
@@ -1,6 +1,6 @@
const utils = require('./utils');
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
+import { load } from 'cheerio';
+import got from '@/utils/got';
module.exports = async (ctx) => {
const response = await got(utils.siteLink, {
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
'user-agent': utils.trueUA,
},
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const articlesLink = $('.post-info-box .post-thumb a')
.toArray()
@@ -29,9 +29,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: $('head title').text(),
link: utils.siteLink,
item: articles,
- };
+ });
};
diff --git a/lib/v2/chinafactcheck/utils.js b/lib/v2/chinafactcheck/utils.js
index a6faf152e..2a6cf6f30 100644
--- a/lib/v2/chinafactcheck/utils.js
+++ b/lib/v2/chinafactcheck/utils.js
@@ -1,7 +1,7 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const { trueUA } = require('@/config').value;
+import { load } from 'cheerio';
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { config } from '@/config';
const siteLink = 'https://chinafactcheck.com';
@@ -26,10 +26,10 @@ const cleanDom = (dom) => {
const getArticleDetail = async (link) => {
const response = await got(link, {
headers: {
- 'user-agent': trueUA,
+ 'user-agent': config.trueUA,
},
});
- const $ = cleanDom(cheerio.load(response.data));
+ const $ = cleanDom(load(response.data));
const title = $('.content-head h2').text().trim();
const author = $('.content-persons p span:last').text().trim();
@@ -56,5 +56,5 @@ module.exports = {
cleanDom,
getArticleDetail,
ArticleDetail,
- trueUA,
+ trueUA: config.trueUA,
};
diff --git a/lib/v2/chinaisa/index.js b/lib/v2/chinaisa/index.js
index b09cebf13..ef1513f23 100644
--- a/lib/v2/chinaisa/index.js
+++ b/lib/v2/chinaisa/index.js
@@ -1,10 +1,10 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { id = '58af05dfb6b4300151760176d2aad0a04c275aaadbb1315039263f021f920dcd' } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 15;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 15;
const rootUrl = 'https://www.chinaisa.org.cn';
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
},
});
- let $ = cheerio.load(response.articleListHtml);
+ let $ = load(response.articleListHtml);
let items = $('ul.list li a')
.slice(0, limit)
@@ -45,7 +45,7 @@ module.exports = async (ctx) => {
const articleContent = detailResponse.article_content;
- const content = cheerio.load(articleContent);
+ const content = load(articleContent);
const matches = articleContent.match(/文章来源:(.*?)日期:(\d+-\d+-\d+)/);
@@ -64,11 +64,11 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- $ = cheerio.load(currentResponse);
+ $ = load(currentResponse);
const icon = new URL($('link[rel="shortcut icon"]').prop('href'), rootUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: `${$('title').text()} - ${subtitle}`,
link: currentUrl,
@@ -79,5 +79,5 @@ module.exports = async (ctx) => {
logo: icon,
subtitle,
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/chinamoney/notice.js b/lib/v2/chinamoney/notice.js
index 21f99ca08..c7b1457de 100644
--- a/lib/v2/chinamoney/notice.js
+++ b/lib/v2/chinamoney/notice.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const { channels } = require('./channels');
module.exports = async (ctx) => {
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
- const $ = cheerio.load(response);
+ const $ = load(response);
const article = $('.article-a-body');
article.find('*').removeAttr('style');
@@ -53,9 +53,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${channels[channelId] ? channels[channelId].title + ' - ' : ''}中国货币网`,
link: `${baseUrl}${channels[channelId]?.urlPath ?? ''}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/chinanews/index.js b/lib/v2/chinanews/index.js
index fa72cd19f..4c2f35cff 100644
--- a/lib/v2/chinanews/index.js
+++ b/lib/v2/chinanews/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
+import { load } from 'cheerio';
const rootUrl = 'https://www.chinanews.com.cn';
@@ -11,14 +11,14 @@ module.exports = async (ctx) => {
method: 'get',
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('a', '.dd_bt')
.map((_, item) => ({
link: rootUrl + $(item).attr('href'),
title: $(item).text(),
}))
.get()
- .slice(0, ctx.query.limit ? (Number.parseInt(ctx.query.limit) > 125 ? 125 : Number.parseInt(ctx.query.limit)) : 50);
+ .slice(0, ctx.req.query('limit') ? (Number.parseInt(ctx.req.query('limit')) > 125 ? 125 : Number.parseInt(ctx.req.query('limit'))) : 50);
const items = await Promise.all(
list.map((item) =>
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
content('.adInContent').remove();
if (content('div.content_desc').length > 0) {
item.description = content('div.content_desc').html();
@@ -56,11 +56,11 @@ module.exports = async (ctx) => {
})
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: '中国新闻网',
link: currentUrl,
description: '中国新闻网(简称“中新网”),由中国新闻社主办,为中央重点新闻网站。',
language: 'zh-cn',
item: items,
- };
+ });
};
diff --git a/lib/v2/chinathinktanks/viewpoint.js b/lib/v2/chinathinktanks/viewpoint.js
index b9ff1674e..b51910ac9 100644
--- a/lib/v2/chinathinktanks/viewpoint.js
+++ b/lib/v2/chinathinktanks/viewpoint.js
@@ -1,19 +1,19 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import timezone from '@/utils/timezone';
const { CookieJar } = require('tough-cookie');
const cookieJar = new CookieJar();
const baseUrl = 'https://www.chinathinktanks.org.cn';
module.exports = async (ctx) => {
- const link = `https://www.chinathinktanks.org.cn/content/list?id=${ctx.params.id}&pt=1`;
+ const link = `https://www.chinathinktanks.org.cn/content/list?id=${ctx.req.param('id')}&pt=1`;
const response = await got(link, {
cookieJar,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let items = $('.main-content-left-list-item')
.toArray()
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
url: item.link,
cookieJar,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const content = $('#art');
item.description = content.html();
item.pubDate = item.pubDate.includes('-') ? timezone(parseDate(item.pubDate, 'YYYY-MM-DD'), +8) : parseRelativeDate(item.pubDate);
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国智库网 —— ${$('title').text().split('_中国智库网')[0]}`,
link,
item: items,
- };
+ });
};
diff --git a/lib/v2/chinaventure/index.js b/lib/v2/chinaventure/index.js
index d2eb79408..6028d9a75 100644
--- a/lib/v2/chinaventure/index.js
+++ b/lib/v2/chinaventure/index.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
const rootUrl = 'https://www.chinaventure.com.cn';
@@ -18,14 +18,14 @@ const nodes = {
};
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const id = ctx.req.param('id');
const currentUrl = rootUrl.concat(id ? `/news/${id}.html` : '/index.html');
const response = await got({
method: 'get',
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('a', '.common_newslist_pc')
.filter(function () {
return $(this).attr('href');
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
link: rootUrl + $(item).attr('href'),
}))
.get()
- .slice(0, ctx.query.limit ? (Number.parseInt(ctx.query.limit) > 20 ? 20 : Number.parseInt(ctx.query.limit)) : 20);
+ .slice(0, ctx.req.query('limit') ? (Number.parseInt(ctx.req.query('limit')) > 20 ? 20 : Number.parseInt(ctx.req.query('limit'))) : 20);
const items = await Promise.all(
list.map((item) =>
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
method: 'get',
url: item.link,
});
- const content = cheerio.load(detailResponse.data);
+ const content = load(detailResponse.data);
item.title = content('h1.maintitle_pc').text();
item.description = content('div.article_slice_pc').html();
item.author = content('div.source_author').text();
@@ -53,11 +53,11 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${nodes[id] ?? '推荐'}-投中网`,
link: currentUrl,
description: '投中网是国内领先的创新经济信息服务平台,拥有立体化媒体矩阵,十多年行业深耕,为创新经济领域核心人群提供深入、独到的智识和洞见,在私募股权投资行业和创新商业领域均拥有权威影响力。',
language: 'zh-cn',
item: items,
- };
+ });
};
diff --git a/lib/v2/chinawriter/index.js b/lib/v2/chinawriter/index.js
index bf1d06eda..423ed17e1 100644
--- a/lib/v2/chinawriter/index.js
+++ b/lib/v2/chinawriter/index.js
@@ -1,18 +1,18 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const { id } = ctx.params;
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 40;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 40;
const rootUrl = 'http://www.chinawriter.com.cn';
const currentUrl = `${new URL(id ?? '', rootUrl).href}/`;
const { data: response } = await got(currentUrl);
- const $ = cheerio.load(response);
+ const $ = load(response);
let items = ($('main div.inner').find('a').length === 0 ? $('body') : $('main div.inner'))
.find('a')
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
try {
const { data: detailResponse } = await got(item.link);
- const content = cheerio.load(detailResponse);
+ const content = load(detailResponse);
content('div.end_shared').remove();
@@ -73,7 +73,7 @@ module.exports = async (ctx) => {
const icon = new URL($('link[rel="icon"]').prop('href'), rootUrl);
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: $('title').text().replaceAll('--', ' - '),
link: currentUrl,
@@ -84,5 +84,5 @@ module.exports = async (ctx) => {
logo: icon,
subtitle: $('meta[name="keywords"]').prop('content'),
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/chsi/hotnews.js b/lib/v2/chsi/hotnews.js
index 69c2eb593..e6e3e2e4c 100644
--- a/lib/v2/chsi/hotnews.js
+++ b/lib/v2/chsi/hotnews.js
@@ -1,12 +1,12 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const host = 'https://yz.chsi.com.cn';
module.exports = async (ctx) => {
const response = await got(host);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('.focus-part .index-hot a');
const items = await Promise.all(
list.map((i, item) => {
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
let itemDate;
if (path) {
const result = await got(itemUrl);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
description = $('#article_dnull').html() ? $('#article_dnull').html().trim() : itemTitle;
if ($('.news-time').text()) {
itemDate = $('.news-time').text();
@@ -39,10 +39,10 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国研究生招生信息网 - 热点`,
link: host,
description: '中国研究生招生信息网 - 热点',
item: items,
- };
+ });
};
diff --git a/lib/v2/chsi/kydt.js b/lib/v2/chsi/kydt.js
index 0d12b89d0..0580d466a 100644
--- a/lib/v2/chsi/kydt.js
+++ b/lib/v2/chsi/kydt.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const host = 'https://yz.chsi.com.cn';
module.exports = async (ctx) => {
const response = await got(`${host}/kyzx/kydt`);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('ul.news-list').children();
const items = await Promise.all(
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
let description = '';
if (!path.startsWith('https://') && !path.startsWith('http://')) {
const result = await got(itemUrl);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
description = $('#article_dnull').html().trim();
} else {
description = itemTitle;
@@ -37,10 +37,10 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国研究生招生信息网 - 考研动态`,
link: `${host}/kyzx/kydt/`,
description: '中国研究生招生信息网 - 考研动态',
item: items,
- };
+ });
};
diff --git a/lib/v2/chsi/kyzx.js b/lib/v2/chsi/kyzx.js
index 0f4bb2749..05e6ab602 100644
--- a/lib/v2/chsi/kyzx.js
+++ b/lib/v2/chsi/kyzx.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const timezone = require('@/utils/timezone');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import timezone from '@/utils/timezone';
+import { parseDate } from '@/utils/parse-date';
const host = 'https://yz.chsi.com.cn';
module.exports = async (ctx) => {
const { type } = ctx.request.params;
const response = await got(`${host}/kyzx/${type}`);
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const typeName = $('.bread-nav .location a').last().text() || '考研资讯';
const list = $('ul.news-list').children();
const items = await Promise.all(
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
let description = '';
if (itemUrl) {
const result = await got(itemUrl);
- const $ = cheerio.load(result.data);
+ const $ = load(result.data);
description = $('#article_dnull').html().trim();
} else {
description = itemTitle;
@@ -38,10 +38,10 @@ module.exports = async (ctx) => {
})
);
- ctx.state.data = {
+ ctx.set('data', {
title: `中国研究生招生信息网 - ${typeName}`,
link: `${host}/kyzx/${type}/`,
description: `中国研究生招生信息网 - ${typeName}`,
item: items,
- };
+ });
};
diff --git a/lib/v2/chuanliu/nice.js b/lib/v2/chuanliu/nice.js
index 7d08ed3a0..b99601d6e 100644
--- a/lib/v2/chuanliu/nice.js
+++ b/lib/v2/chuanliu/nice.js
@@ -1,14 +1,14 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
-const { art } = require('@/utils/render');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
const path = require('path');
const md = require('markdown-it')({
html: true,
});
module.exports = async (ctx) => {
- const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 100;
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 100;
const rootUrl = 'https://chuanliu.org';
const apiRootUrl = 'https://s.chuanliu.org';
@@ -57,11 +57,11 @@ module.exports = async (ctx) => {
const { data: currentResponse } = await got(currentUrl);
- const $ = cheerio.load(currentResponse);
+ const $ = load(currentResponse);
const icon = new URL($('link[rel="shortcut icon"]').prop('href'), currentUrl).href;
- ctx.state.data = {
+ ctx.set('data', {
item: items,
title: $('title').text(),
link: currentUrl,
@@ -72,5 +72,5 @@ module.exports = async (ctx) => {
subtitle: $('title').text(),
author: $('meta[name="author"]').prop('content'),
allowEmpty: true,
- };
+ });
};
diff --git a/lib/v2/cib/whpj.js b/lib/v2/cib/whpj.js
index 8ae3d5af9..dfa2fe9ae 100644
--- a/lib/v2/cib/whpj.js
+++ b/lib/v2/cib/whpj.js
@@ -1,9 +1,9 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const { parseDate } = require('@/utils/parse-date');
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
const https = require('https');
const crypto = require('crypto');
-const config = require('@/config').value;
+import { config } from '@/config';
module.exports = async (ctx) => {
// fix unsafe legacy renegotiation disabled
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const response = await got('https://personalbank.cib.com.cn/pers/main/pubinfo/ifxQuotationQuery.do', { agent: { https: agent } });
const cookies = response.headers['set-cookie'].map((item) => item.split(';')[0]).join(';');
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
let date = $('div.main-body').find('div.labe_text').text();
date = date.split('\n\t')[1].replace('日期:', '').trim();
date = date.substring(0, 11) + date.substring(15);
@@ -35,9 +35,9 @@ module.exports = async (ctx) => {
false
);
- const format = ctx.params.format;
+ const format = ctx.req.param('format');
- ctx.state.data = {
+ ctx.set('data', {
title: '中国兴业银行外汇牌价',
link: 'https://personalbank.cib.com.cn/pers/main/pubinfo/ifxQuotationQuery.do',
item: data.rows.map((item) => {
@@ -60,7 +60,7 @@ module.exports = async (ctx) => {
guid: `${item.cell[0]} ${item.cell[1]} ${date}`,
};
}),
- };
+ });
};
function formatTitle(name, xhmr, xcmr, xhmc, xcmc, content, format) {
diff --git a/lib/v2/ciidbnu/index.js b/lib/v2/ciidbnu/index.js
index 87f26071d..dc7feaf12 100644
--- a/lib/v2/ciidbnu/index.js
+++ b/lib/v2/ciidbnu/index.js
@@ -1,11 +1,11 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { load } from 'cheerio';
const iconv = require('iconv-lite');
-const { parseDate } = require('@/utils/parse-date');
-const timezone = require('@/utils/timezone');
+import { parseDate } from '@/utils/parse-date';
+import timezone from '@/utils/timezone';
module.exports = async (ctx) => {
- const id = ctx.params.id ?? '1';
+ const id = ctx.req.param('id') ?? '1';
const rootUrl = 'http://www.ciidbnu.org';
const currentUrl = `${rootUrl}/new1.asp?pagetype=${id}`;
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
url: currentUrl,
});
- const $ = cheerio.load(response.data);
+ const $ = load(response.data);
const list = $('#newsrightlist a')
.slice(0, 10)
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
url: item.link,
responseType: 'buffer',
});
- const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
+ const content = load(iconv.decode(detailResponse.data, 'gbk'));
item.description = content('#text').html();
item.pubDate = timezone(parseDate(content('.t8').eq(0).text(), 'YYYY/M/D H:mm:ss'), +8);
@@ -49,9 +49,9 @@ module.exports = async (ctx) => {
)
);
- ctx.state.data = {
+ ctx.set('data', {
title: `${$('h3').text()} - 中国收入分配研究院`,
link: currentUrl,
item: items,
- };
+ });
};
diff --git a/lib/v2/civitai/discussions.js b/lib/v2/civitai/discussions.js
index cf7b51d0b..edb9b0da4 100644
--- a/lib/v2/civitai/discussions.js
+++ b/lib/v2/civitai/discussions.js
@@ -1,7 +1,7 @@
-const got = require('@/utils/got');
-const { parseDate } = require('@/utils/parse-date');
-const config = require('@/config').value;
-const cheerio = require('cheerio');
+import got from '@/utils/got';
+import { parseDate } from '@/utils/parse-date';
+import { config } from '@/config';
+import { load } from 'cheerio';
module.exports = async (ctx) => {
const params = ctx.params;
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
.map((item) =>
item.images?.length || item.content
? {
- title: item.content ? cheerio.load(item.content).text() : 'Image',
+ title: item.content ? load(item.content).text() : 'Image',
link: `https://civitai.com/models/${params.modelId}`,
description: `${(item.images || []).map((image) => `