From 0e7b14e7184164081dae76a0f48c05ff5b009b03 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 2 Apr 2020 21:21:46 +0800 Subject: [PATCH] chore(deps-dev): bump prettier from 1.19.1 to 2.0.2 --- docs/.vuepress/config.js | 2 +- docs/en/joinus/README.md | 29 ++---- docs/joinus/README.md | 29 ++---- lib/middleware/cache.js | 6 +- lib/routes/005tv/zx.js | 35 ++------ lib/routes/10000link/news.js | 4 +- lib/routes/12306/zxdt.js | 15 +--- lib/routes/1x/magazine.js | 4 +- lib/routes/2048/bbs.js | 14 +-- lib/routes/21caijing/channel.js | 2 +- lib/routes/3dm/game.js | 8 +- lib/routes/3dm/news_center.js | 26 ++---- lib/routes/3ycy/home.js | 5 +- lib/routes/99percentinvisible/transcript.js | 4 +- lib/routes/9to5/utils.js | 5 +- lib/routes/aeon/category.js | 9 +- lib/routes/aisixiang/column.js | 4 +- lib/routes/aisixiang/ranking.js | 4 +- lib/routes/aisixiang/utils.js | 13 +-- lib/routes/algocasts/all.js | 9 +- lib/routes/aliyun/database_month.js | 12 +-- lib/routes/aliyun/notice.js | 16 +--- lib/routes/allpoetry/order.js | 16 +--- lib/routes/andyt/index.js | 23 +---- lib/routes/anime1/anime.js | 4 +- lib/routes/anime1/search.js | 4 +- lib/routes/animen/news.js | 2 +- lib/routes/anitama/channel.js | 4 +- lib/routes/aozora/newbook.js | 18 +--- lib/routes/apkpure/versions.js | 23 +---- lib/routes/apnews/topics.js | 15 +--- lib/routes/apple/appstore/update.js | 6 +- lib/routes/apple/exchange_repair.js | 4 +- lib/routes/aptonic/action.js | 6 +- lib/routes/aqk/vul.js | 12 +-- lib/routes/arknights/news.js | 17 +--- lib/routes/asahichinese-f/index.js | 18 ++-- lib/routes/asahichinese-j/index.js | 18 ++-- lib/routes/atfd/index.js | 2 +- lib/routes/autotrader/index.js | 10 +-- lib/routes/babykingdom/index.js | 17 +--- lib/routes/bahamut/utils.js | 4 +- lib/routes/bangumi/group/reply.js | 10 +-- lib/routes/bangumi/subject/comments.js | 9 +- lib/routes/banyuetan/index.js | 14 +-- lib/routes/bbc/utils.js | 8 +- lib/routes/bilibili/blackboard.js | 2 +- lib/routes/bjp/apod.js | 7 +- lib/routes/bjx/huanbao.js | 10 +-- lib/routes/blogread/newest.js | 10 +-- lib/routes/blogs/diygod/gk.js | 6 +- lib/routes/blogs/hedwig.js | 13 +-- lib/routes/blogs/wang54.js | 12 +-- lib/routes/boc/whpj.js | 32 ++----- lib/routes/caixin/category.js | 23 +---- lib/routes/cartoonmad/comic.js | 14 +-- lib/routes/cctv/xwlb.js | 9 +- lib/routes/cell/cell/index.js | 16 +--- lib/routes/cell/cover.js | 7 +- lib/routes/centbrowser/history.js | 5 +- lib/routes/checkee/index.js | 48 +++------- lib/routes/checkra1n/releases.js | 5 +- lib/routes/chinadaily/english.js | 4 +- lib/routes/chinadialogue/column.js | 4 +- lib/routes/chinadialogue/topics.js | 4 +- lib/routes/chiphell/forum.js | 27 ++---- lib/routes/chocolatey/software.js | 4 +- lib/routes/chrome/extensions.js | 4 +- lib/routes/ciweimao/chapter.js | 2 +- lib/routes/codeceo/category.js | 4 +- lib/routes/codeceo/home.js | 4 +- lib/routes/coronavirus/sg-moh.js | 15 +--- lib/routes/csrc/auditstatus.js | 14 +-- lib/routes/csrc/fashenwei.js | 5 +- lib/routes/ctfhub/index.js | 2 +- lib/routes/curseforge/generalfiles.js | 31 ++----- lib/routes/cyzone/author.js | 2 +- lib/routes/cyzone/label.js | 2 +- lib/routes/d2/daily.js | 4 +- lib/routes/dapenti/utils.js | 4 +- lib/routes/dengekionline/new.js | 4 +- lib/routes/dianping/user.js | 4 +- lib/routes/digitaling/article.js | 4 +- lib/routes/digitaling/index.js | 4 +- lib/routes/digitaling/project.js | 4 +- lib/routes/dilidili/fanju.js | 6 +- lib/routes/discuz/discuz.js | 24 ++--- lib/routes/docschina/jsweekly.js | 8 +- lib/routes/donews/index.js | 16 +--- lib/routes/dongqiudi/result.js | 12 +-- lib/routes/dongqiudi/special.js | 4 +- lib/routes/douban/celebrity.js | 17 +--- lib/routes/douban/commercialpress/latest.js | 7 +- lib/routes/douban/doulist.js | 70 ++++----------- lib/routes/douban/explore.js | 10 +-- lib/routes/douban/explore_column.js | 14 +-- lib/routes/douban/group.js | 2 +- lib/routes/douban/latest_book.js | 14 +-- lib/routes/douban/latest_music.js | 8 +- lib/routes/dribbble/utils.js | 4 +- lib/routes/dsndsht23/index.js | 21 +---- lib/routes/dsndsht23/pictures.js | 17 ++-- lib/routes/duozhi/index.js | 16 +--- lib/routes/duozhuayu/search.js | 4 +- lib/routes/dysfz/index.js | 18 +--- lib/routes/dytt/index.js | 6 +- lib/routes/eeo/index.js | 12 +-- lib/routes/elife/index.js | 4 +- lib/routes/embassy/index.js | 7 +- lib/routes/facebook/page.js | 20 +---- lib/routes/fanfou/utils.js | 2 +- lib/routes/fdroid/apprelease.js | 41 ++------- lib/routes/finviz/news.js | 18 +--- lib/routes/firefox/addons.js | 6 +- lib/routes/flyertea/utils.js | 2 +- lib/routes/galaxylab/index.js | 8 +- lib/routes/gamersky/ent.js | 22 ++--- lib/routes/gamersky/news.js | 20 ++--- lib/routes/gaoqing/utils.js | 4 +- lib/routes/gaoqingla/latest.js | 4 +- lib/routes/gbcc/trust.js | 4 +- lib/routes/gcores/category.js | 8 +- lib/routes/getitfree/utils.js | 8 +- lib/routes/gitea/blog.js | 10 +-- lib/routes/github/search.js | 17 +--- lib/routes/github/trending.js | 10 +-- lib/routes/google/citations.js | 12 +-- lib/routes/google/news.js | 33 ++----- lib/routes/gouhuo/cache.js | 10 +-- lib/routes/gouhuo/strategy.js | 4 +- lib/routes/gov/customs/list.js | 14 +-- lib/routes/gov/hunan/notice.js | 6 +- lib/routes/gov/province/jiangsu/getContent.js | 4 +- lib/routes/gov/sapprft/7026.js | 36 ++------ lib/routes/gov/suzhou/doc.js | 4 +- lib/routes/gov/suzhou/news.js | 7 +- lib/routes/gracg/user.js | 14 +-- lib/routes/gradcafe/result.js | 23 ++--- lib/routes/greasyfork/scripts.js | 4 +- lib/routes/guanchazhe/index.js | 88 ++++--------------- lib/routes/guanchazhe/topic.js | 5 +- lib/routes/guardian/utils.js | 8 +- lib/routes/guat/news.js | 11 +-- lib/routes/gushiwen/recommend.js | 18 ++-- lib/routes/hackernews/story.js | 6 +- lib/routes/haimaoba/comics.js | 10 +-- lib/routes/hatena/anonymous_diary/archive.js | 13 +-- lib/routes/hinatazaka46/blog.js | 15 +--- lib/routes/hinatazaka46/news.js | 10 +-- lib/routes/hko/weather.js | 11 +-- lib/routes/hopper/index.js | 7 +- lib/routes/houxu/events.js | 32 ++----- lib/routes/hpoi/index.js | 15 +--- lib/routes/hpoi/info.js | 15 +--- lib/routes/hpoi/user.js | 15 +--- lib/routes/hupu/bbs.js | 15 +--- lib/routes/huxiu/author.js | 4 +- lib/routes/huxiu/utils.js | 4 +- lib/routes/ikea/uk/new.js | 24 ++--- lib/routes/ikea/uk/offer.js | 25 ++---- lib/routes/instapaper/person.js | 14 +-- lib/routes/iplay/home.js | 4 +- lib/routes/ipsw/index.js | 40 ++------- lib/routes/iqiyi/dongman.js | 21 ++--- lib/routes/iqiyi/video.js | 20 +---- lib/routes/ithome/ranking.js | 14 +-- lib/routes/itslide/new.js | 28 ++---- lib/routes/jandan/pic.js | 10 +-- lib/routes/japanpost/index.js | 28 ++---- lib/routes/japanpost/utils.js | 20 ++--- lib/routes/javbus/util.js | 24 ++--- lib/routes/jdlingyu/index.js | 10 +-- lib/routes/jiemian/list.js | 8 +- lib/routes/jingdong/zhongchou.js | 28 ++---- lib/routes/jinritoutiao/keyword.js | 2 +- lib/routes/juejin/trending.js | 2 +- lib/routes/juesheng/index.js | 20 +---- lib/routes/keyakizaka46/blog.js | 16 +--- lib/routes/keyakizaka46/news.js | 10 +-- lib/routes/kuaidi100/utils.js | 5 +- lib/routes/latexstudio/home.js | 15 +--- lib/routes/learnku/topic.js | 8 +- lib/routes/leetcode/articles.js | 24 ++--- lib/routes/leetcode/check-us.js | 34 ++----- lib/routes/leetcode/utils.js | 12 +-- lib/routes/letterboxd/utils.js | 2 +- lib/routes/lfsyd/index.js | 2 +- lib/routes/linkedkeeper/index.js | 29 +----- lib/routes/lofter/tag.js | 12 +-- lib/routes/loveheaven/update.js | 2 +- lib/routes/ltaaa/_article.js | 7 +- lib/routes/luogu/contest.js | 21 +---- lib/routes/luogu/daily.js | 11 +-- lib/routes/maitta/index.js | 29 +----- lib/routes/manhuadb/comics.js | 8 +- lib/routes/manhuagui/comic.js | 10 +-- lib/routes/meipai/user.js | 4 +- lib/routes/metacritic/release.js | 20 ++--- lib/routes/mhw/news.js | 5 +- lib/routes/mhw/update.js | 9 +- lib/routes/moxingnet/index.js | 9 +- lib/routes/mpaypass/main.js | 18 ++-- lib/routes/mpaypass/news.js | 5 +- lib/routes/mzitu/tags.js | 8 +- lib/routes/mzitu/util.js | 12 +-- lib/routes/namoc/announcement.js | 11 +-- lib/routes/namoc/exhibition.js | 36 ++------ lib/routes/namoc/media.js | 16 +--- lib/routes/namoc/news.js | 16 +--- lib/routes/namoc/specials.js | 4 +- lib/routes/natgeo/natgeo.js | 15 +--- lib/routes/nature/highlight.js | 5 +- lib/routes/nature/news.js | 5 +- lib/routes/nature/research.js | 7 +- lib/routes/nbd/article.js | 22 ++--- lib/routes/netease/ds.js | 7 +- lib/routes/netease/open/vip.js | 8 +- lib/routes/nfmovies/index.js | 2 +- lib/routes/nga/post.js | 7 +- lib/routes/nintendo/direct.js | 12 +-- lib/routes/nintendo/system-update.js | 6 +- lib/routes/nogizaka46/news.js | 15 +--- lib/routes/noi/rg-news.js | 19 +--- lib/routes/novel/axdzs.js | 9 +- lib/routes/novel/biquge.js | 12 +-- lib/routes/novel/booksky.js | 21 +---- lib/routes/novel/dcrsw.js | 14 +-- lib/routes/novel/shuquge.js | 8 +- lib/routes/novel/wenxuemi.js | 11 +-- lib/routes/novel/zhaishuyuan.js | 5 +- lib/routes/nowcoder/discuss.js | 16 +--- lib/routes/nvidia/webdriverupdate.js | 2 +- lib/routes/nytimes/index.js | 4 +- lib/routes/nytimes/utils.js | 8 +- lib/routes/oilprice/index.js | 16 +--- lib/routes/one/index.js | 12 +-- lib/routes/oschina/news.js | 4 +- lib/routes/owspace/read.js | 5 +- lib/routes/p-articles/contributors.js | 7 +- lib/routes/p-articles/section.js | 7 +- lib/routes/p-articles/utils.js | 8 +- lib/routes/paidai/bbs.js | 14 +-- lib/routes/paidai/index.js | 15 +--- lib/routes/paidai/news.js | 15 +--- lib/routes/paidai/utils.js | 4 +- lib/routes/pcr/news-tw.js | 8 +- lib/routes/pcr/news.js | 5 +- lib/routes/pediy/topic.js | 14 +-- lib/routes/people/env.js | 18 ++-- lib/routes/people/opinion.js | 18 ++-- lib/routes/people/xjpjh.js | 14 +-- lib/routes/pgyer/app.js | 33 ++----- lib/routes/pianyuan/app.js | 14 +-- lib/routes/piapro/public.js | 14 +-- lib/routes/piapro/user.js | 10 +-- lib/routes/pigtails/index.js | 5 +- lib/routes/pingwest/status.js | 5 +- lib/routes/pingwest/utils.js | 10 +-- lib/routes/pixiv/token.js | 2 +- lib/routes/ps/ps4updates.js | 20 ++--- lib/routes/ps/trophy.js | 44 ++-------- lib/routes/psnine/game.js | 25 ++---- lib/routes/psnine/index.js | 20 ++--- lib/routes/psnine/news.js | 20 ++--- lib/routes/psnine/shuzhe.js | 24 ++--- lib/routes/psnine/trade.js | 22 ++--- lib/routes/pubmed/trending.js | 6 +- lib/routes/qidian/forum.js | 11 +-- lib/routes/qtfyfl/category.js | 18 +--- lib/routes/quantamagazine/archive.js | 4 +- lib/routes/remote-work/index.js | 4 +- lib/routes/rsshub/routes.js | 14 +-- lib/routes/rsshub/sponsors.js | 8 +- lib/routes/sciencemag/cover.js | 2 +- lib/routes/sciencemag/current.js | 4 +- lib/routes/sciencemag/early.js | 4 +- lib/routes/sckjt/news.js | 17 +--- lib/routes/security/pulses.js | 20 ++--- lib/routes/segmentfault/channel.js | 28 ++---- lib/routes/shuhui/comics.js | 4 +- lib/routes/simonsfoundation/recommend.js | 26 +----- lib/routes/sketch/beta.js | 41 ++------- lib/routes/sketch/updates.js | 27 ++---- lib/routes/smzdm/haowen.js | 14 +-- lib/routes/smzdm/haowen_fenlei.js | 19 ++-- lib/routes/smzdm/keyword.js | 30 +------ lib/routes/solidot/_article.js | 12 +-- lib/routes/soundcloud/utils.js | 15 +--- lib/routes/steam/search.js | 15 +--- lib/routes/szse/notice.js | 21 +---- lib/routes/t66y/index.js | 27 ++---- lib/routes/t66y/post.js | 14 +-- lib/routes/taptap/review.js | 23 +---- lib/routes/tencent/bugly/changelog.js | 4 +- lib/routes/tencent/gameinstitute/community.js | 4 +- lib/routes/tencent/guyu/channel.js | 4 +- lib/routes/tencent/qcloud/mlvb/changelog.js | 6 +- lib/routes/tencent/wechat/announce.js | 2 +- lib/routes/tencent/wechat/csm.js | 22 +---- .../wechat/wechat-open/community/announce.js | 2 +- lib/routes/tencent/wechat/wemp.js | 25 ++---- lib/routes/thepaper/839studio/category.js | 13 +-- lib/routes/thepaper/839studio/studio.js | 5 +- lib/routes/thepaper/utils.js | 21 +---- lib/routes/thunderbird/release.js | 8 +- lib/routes/tianya/comments.js | 8 +- lib/routes/tianya/index.js | 4 +- lib/routes/tianya/user.js | 4 +- lib/routes/tingshuitz/dongguan.js | 6 +- lib/routes/tingshuitz/xiaoshan.js | 7 +- lib/routes/tingshuitz/yangjiang.js | 15 +--- lib/routes/titsguru/util.js | 4 +- lib/routes/tophub/index.js | 14 +-- lib/routes/toutiao/today.js | 27 +----- lib/routes/toutiao/user.js | 31 ++----- lib/routes/tuicool/mags.js | 12 +-- lib/routes/ui-cn/article.js | 28 ++---- lib/routes/universities/bit/cs/cs.js | 4 +- lib/routes/universities/bit/cs/utils.js | 4 +- lib/routes/universities/bit/jwc/jwc.js | 4 +- lib/routes/universities/buaa/news/index.js | 4 +- lib/routes/universities/bupt/grs.js | 11 +-- lib/routes/universities/bupt/utils.js | 2 +- lib/routes/universities/bupt/yz.js | 4 +- lib/routes/universities/cas/sim/academic.js | 19 +--- lib/routes/universities/ccnu/career.js | 13 +-- lib/routes/universities/cpu/home.js | 4 +- lib/routes/universities/cpu/jwc.js | 4 +- lib/routes/universities/cpu/yjsy.js | 4 +- .../universities/cqu/jwc/announcement.js | 6 +- lib/routes/universities/cqust/jw.js | 7 +- lib/routes/universities/cqust/lib.js | 4 +- lib/routes/universities/cuit/cxxww.js | 10 +-- lib/routes/universities/dgut/jwc.js | 16 +--- lib/routes/universities/dgut/xsc.js | 11 +-- lib/routes/universities/dlmu/news.js | 6 +- lib/routes/universities/dlu/jiaowu/news.js | 8 +- lib/routes/universities/gdou/jwc/jwtz.js | 4 +- lib/routes/universities/hit/jwc.js | 12 +-- lib/routes/universities/hit/today.js | 11 +-- lib/routes/universities/hust/aia/news.js | 4 +- lib/routes/universities/hust/aia/notice.js | 9 +- lib/routes/universities/jgsu/jwc.js | 23 +---- lib/routes/universities/kmust/jwc.js | 7 +- lib/routes/universities/lit/tw.js | 7 +- lib/routes/universities/lit/xwzx.js | 4 +- .../universities/mit/graduateadmissions.js | 4 +- lib/routes/universities/nchu/jwc.js | 12 +-- lib/routes/universities/ncwu/notice.js | 30 +------ lib/routes/universities/neu/news.js | 14 ++- lib/routes/universities/njfu/jwc.js | 17 +--- lib/routes/universities/njtech/jwc.js | 8 +- lib/routes/universities/njupt/jwc.js | 12 +-- lib/routes/universities/njust/eo/index.js | 15 +--- lib/routes/universities/njust/gs/index.js | 15 +--- lib/routes/universities/nuaa/cs/index.js | 14 +-- lib/routes/universities/nuaa/yjsy/yjsy.js | 4 +- lib/routes/universities/nuc/index.js | 7 +- lib/routes/universities/nuist/bulletin.js | 4 +- lib/routes/universities/nuist/cas.js | 36 ++------ lib/routes/universities/nuist/jwc.js | 14 +-- lib/routes/universities/nuist/library/lib.js | 22 +---- lib/routes/universities/nuist/scs.js | 4 +- lib/routes/universities/nuist/sese.js | 12 +-- lib/routes/universities/nuist/xgc.js | 12 +-- lib/routes/universities/nuist/yjs.js | 12 +-- lib/routes/universities/ouc/it.js | 4 +- lib/routes/universities/pku/bbs/hot.js | 13 +-- lib/routes/universities/pku/cls/lecture.js | 5 +- lib/routes/universities/pku/rccp/mzyt.js | 11 +-- lib/routes/universities/scnu/cs/match.js | 4 +- lib/routes/universities/scnu/jw.js | 8 +- lib/routes/universities/scnu/library.js | 4 +- lib/routes/universities/scu/jwc.js | 5 +- lib/routes/universities/scu/xg.js | 4 +- lib/routes/universities/sdu/cmse.js | 8 +- lib/routes/universities/sdu/cs.js | 10 +-- lib/routes/universities/sdu/epe.js | 8 +- lib/routes/universities/sdu/mech.js | 8 +- lib/routes/universities/sdu/sc.js | 13 +-- lib/routes/universities/seu/cse/index.js | 14 +-- lib/routes/universities/seu/radio/academic.js | 24 ++--- .../shanghaitech/sist/activity.js | 14 +-- lib/routes/universities/shmtu/jwc.js | 24 ++--- lib/routes/universities/shmtu/www.js | 26 ++---- lib/routes/universities/shu/jwc.js | 18 +--- lib/routes/universities/sjtu/gs/tzgg.js | 4 +- lib/routes/universities/sjtu/gs/utils.js | 4 +- lib/routes/universities/sjtu/jwc.js | 4 +- .../universities/sjtu/seiee/academic.js | 12 +-- lib/routes/universities/sjtu/seiee/bjwb.js | 14 +-- lib/routes/universities/sjtu/seiee/utils.js | 2 +- lib/routes/universities/sjtu/seiee/xsb.js | 14 +-- .../universities/sjtu/tongqu/activity.js | 4 +- lib/routes/universities/sjtu/yzb/zkxx.js | 12 +-- lib/routes/universities/swufe/seie/index.js | 14 +-- lib/routes/universities/swust/cs.js | 10 +-- lib/routes/universities/szu/yz/index.js | 4 +- lib/routes/universities/szu/yz/utils.js | 8 +- lib/routes/universities/tju/sse/notice.js | 4 +- lib/routes/universities/uestc/auto.js | 21 +---- lib/routes/universities/uestc/cs.js | 25 ++---- lib/routes/universities/uestc/jwc.js | 7 +- lib/routes/universities/uestc/news.js | 7 +- lib/routes/universities/whu/cs.js | 21 +---- lib/routes/universities/whu/news.js | 4 +- lib/routes/universities/xidian/jwc.js | 11 +-- lib/routes/universities/xjtu/dean.js | 17 ++-- lib/routes/universities/yzu/home.js | 2 +- lib/routes/universities/yzu/yjszs.js | 2 +- lib/routes/universities/zjgsu/gsgg/scripts.js | 11 +-- lib/routes/universities/zjgsu/xszq/scripts.js | 11 +-- lib/routes/universities/zju/career/index.js | 10 +-- lib/routes/universities/zju/grs/index.js | 9 +- lib/routes/universities/zju/list.js | 12 +-- lib/routes/universities/zju/physics/index.js | 4 +- .../universities/zucc/cssearch/index.js | 8 +- lib/routes/universities/zucc/news/index.js | 17 +--- lib/routes/universities/zzu/news.js | 18 +--- lib/routes/universities/zzu/soft/news.js | 16 +--- lib/routes/v2ex/post.js | 5 +- lib/routes/verge/index.js | 4 +- lib/routes/vol/lastupdate.js | 5 +- lib/routes/weibo/timeline.js | 18 ++-- lib/routes/weibo/utils.js | 4 +- lib/routes/wenku8/chapter.js | 2 +- lib/routes/whb/zhuzhan.js | 4 +- lib/routes/wired/tag.js | 16 +--- lib/routes/wolley/host.js | 16 +--- lib/routes/wolley/user.js | 10 +-- lib/routes/woshipm/bookmarks.js | 4 +- lib/routes/woshipm/user_article.js | 18 ++-- lib/routes/woshipm/wen.js | 10 +-- lib/routes/x-mol/news.js | 18 +--- lib/routes/x-mol/paper.js | 4 +- lib/routes/xiachufang/utils.js | 16 +--- lib/routes/xici/index.js | 20 ++--- lib/routes/xueqiu/stock_info.js | 4 +- lib/routes/xuetangx/course_list.js | 9 +- lib/routes/yahoo-jp-tv/index.js | 10 +-- lib/routes/yidoutang/guide.js | 4 +- lib/routes/yidoutang/mtest.js | 5 +- lib/routes/yystv/category.js | 44 +++------- lib/routes/yystv/recommend.js | 44 +++------- lib/routes/zaker/focusread.js | 10 +-- lib/routes/zaker/source.js | 10 +-- lib/routes/zaobao/util.js | 8 +- lib/routes/zcfy/hot.js | 14 +-- lib/routes/zcfy/index.js | 18 +--- lib/routes/zcool/recommend.js | 17 +--- lib/routes/zcool/top.js | 15 +--- lib/routes/zhibo8/forum.js | 2 +- lib/routes/zhibo8/post.js | 5 +- lib/routes/zhihu/posts.js | 10 +-- lib/routes/zhihu/utils.js | 2 +- lib/routes/zhihu/weekly.js | 21 ++--- lib/routes/zhihu/zhuanlan.js | 10 +-- lib/routes/zhishifenzi/depth.js | 6 +- lib/routes/zhishifenzi/innovation.js | 11 +-- lib/routes/zhishifenzi/news.js | 11 +-- lib/utils/dateParser.js | 5 +- lib/utils/md5.js | 5 +- lib/utils/request-wrapper.js | 2 +- package.json | 2 +- test/middleware/debug.js | 10 +-- test/utils/common-config.js | 2 +- test/utils/dateParser.js | 60 ++----------- test/utils/got.js | 6 +- test/utils/request-wrapper.js | 6 +- test/utils/rss-parser.js | 2 +- yarn.lock | 8 +- 471 files changed, 1237 insertions(+), 4457 deletions(-) diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 691eb539e9..8790544dff 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -34,7 +34,7 @@ module.exports = { }, }, markdown: { - slugify: function(s) { + slugify: function (s) { return _slugify( pinyin(s, { style: pinyin.STYLE_NORMAL, diff --git a/docs/en/joinus/README.md b/docs/en/joinus/README.md index a65b8260d5..042a21a4d4 100644 --- a/docs/en/joinus/README.md +++ b/docs/en/joinus/README.md @@ -143,14 +143,8 @@ Create a new js script in [/lib/routes/](https://github.com/DIYgod/RSSHub/tree/m item = $(item); itemPicUrl = `${item.find('a.cover').attr('style')}`.replace('background-image:url(', '').replace(')', ''); return { - title: item - .find('.title a') - .first() - .text(), - description: `作者:${item - .find('.usr-pic a') - .last() - .text()}
描述:${item.find('.content p').text()}
`, + title: item.find('.title a').first().text(), + description: `作者:${item.find('.usr-pic a').last().text()}
描述:${item.find('.content p').text()}
`, link: item.find('.title a').attr('href'), }; }) @@ -205,22 +199,11 @@ Create a new js script in [/lib/routes/](https://github.com/DIYgod/RSSHub/tree/m item: list .map((i, item) => ({ // the article title - title: $(item) - .find('.item-title a') - .text() - .trim(), + title: $(item).find('.item-title a').text().trim(), // the article link - link: url.resolve( - link, - $(item) - .find('.item-title a') - .attr('href') - ), + link: url.resolve(link, $(item).find('.item-title a').attr('href')), // the article author - author: $(item) - .find('.item-author') - .text() - .trim(), + author: $(item).find('.item-author').text().trim(), })) .get(), // use cheerio get() method to transform a cheerio node object array into a node array }; @@ -300,7 +283,7 @@ const description = await ctx.cache.tryGet(link, async () => { const result = await got.get(link); const $ = cheerio.load(result.data); - $('img').each(function(i, e) { + $('img').each(function (i, e) { $(e).attr('src', $(e).attr('data-src')); }); diff --git a/docs/joinus/README.md b/docs/joinus/README.md index c3d1d2771f..c2df617bf8 100644 --- a/docs/joinus/README.md +++ b/docs/joinus/README.md @@ -142,14 +142,8 @@ sidebar: auto item = $(item); itemPicUrl = `${item.find('a.cover').attr('style')}`.replace('background-image:url(', '').replace(')', ''); return { - title: item - .find('.title a') - .first() - .text(), - description: `作者:${item - .find('.usr-pic a') - .last() - .text()}
描述:${item.find('.content p').text()}
`, + title: item.find('.title a').first().text(), + description: `作者:${item.find('.usr-pic a').last().text()}
描述:${item.find('.content p').text()}
`, link: item.find('.title a').attr('href'), }; }) @@ -205,22 +199,11 @@ sidebar: auto item: list .map((i, item) => ({ // 文章标题 - title: $(item) - .find('.item-title a') - .text() - .trim(), + title: $(item).find('.item-title a').text().trim(), // 文章链接 - link: url.resolve( - link, - $(item) - .find('.item-title a') - .attr('href') - ), + link: url.resolve(link, $(item).find('.item-title a').attr('href')), // 文章作者 - author: $(item) - .find('.item-author') - .text() - .trim(), + author: $(item).find('.item-author').text().trim(), })) .get(), // cheerio get() 方法将 cheerio node 对象数组转换为 node 对象数组 }; @@ -299,7 +282,7 @@ const description = await ctx.cache.tryGet(link, async () => { const result = await got.get(link); const $ = cheerio.load(result.data); - $('img').each(function(i, e) { + $('img').each(function (i, e) { $(e).attr('src', $(e).attr('data-src')); }); diff --git a/lib/middleware/cache.js b/lib/middleware/cache.js index b1afffb491..1500f89c57 100644 --- a/lib/middleware/cache.js +++ b/lib/middleware/cache.js @@ -5,7 +5,7 @@ const md5 = require('@/utils/md5'); const config = require('@/config').value; const logger = require('@/utils/logger'); -module.exports = function(app, options = {}) { +module.exports = function (app, options = {}) { let available = false; const { prefix = 'koa-redis-cache:', expire = config.cache.routeExpire, passParam = '', maxLength = Infinity, ignoreQuery = true } = options; @@ -43,7 +43,7 @@ module.exports = function(app, options = {}) { return value; } }, - set: function(key, value, maxAge = config.cache.contentExpire) { + set: function (key, value, maxAge = config.cache.contentExpire) { if (!available) { return; } @@ -127,7 +127,7 @@ module.exports = function(app, options = {}) { }; } - app.context.cache.tryGet = async function(key, getValueFunc, maxAge = config.cache.contentExpire) { + app.context.cache.tryGet = async function (key, getValueFunc, maxAge = config.cache.contentExpire) { let v = await this.get(key); if (!v) { v = await getValueFunc(); diff --git a/lib/routes/005tv/zx.js b/lib/routes/005tv/zx.js index 92af482e87..e60db0ce40 100644 --- a/lib/routes/005tv/zx.js +++ b/lib/routes/005tv/zx.js @@ -13,36 +13,11 @@ module.exports = async (ctx) => { description: '二次元资讯', item: list .map((index, item) => ({ - title: $(item) - .find('h3 > a') - .text() - .trim(), - description: `
- ${$(item) - .find('div.p-row') - .text()}`, - link: $(item) - .find('h3 > a') - .attr('href'), - pubDate: new Date( - $(item) - .find('span.fr.time') - .text() - .trim() - .substr(0, 4), - $(item) - .find('span.fr.time') - .text() - .trim() - .substr(5, 2), - $(item) - .find('span.fr.time') - .text() - .trim() - .substr(8, 4) - ).toUTCString(), + title: $(item).find('h3 > a').text().trim(), + description: `
+ ${$(item).find('div.p-row').text()}`, + link: $(item).find('h3 > a').attr('href'), + pubDate: new Date($(item).find('span.fr.time').text().trim().substr(0, 4), $(item).find('span.fr.time').text().trim().substr(5, 2), $(item).find('span.fr.time').text().trim().substr(8, 4)).toUTCString(), })) .get(), }; diff --git a/lib/routes/10000link/news.js b/lib/routes/10000link/news.js index dee7fb9b9e..f7934e5192 100644 --- a/lib/routes/10000link/news.js +++ b/lib/routes/10000link/news.js @@ -51,9 +51,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `万联网 ${$('.t-h2') - .text() - .replace(' |资讯频道', '')}`, + title: `万联网 ${$('.t-h2').text().replace(' |资讯频道', '')}`, link: pageUrl, description: $('meta[name="Description"]').attr('content'), item: items, diff --git a/lib/routes/12306/zxdt.js b/lib/routes/12306/zxdt.js index 998d02c079..bc67ff8302 100644 --- a/lib/routes/12306/zxdt.js +++ b/lib/routes/12306/zxdt.js @@ -18,18 +18,11 @@ module.exports = async (ctx) => { const name = $('div.nav_center > a:nth-child(4)').text(); const list = $('#newList > ul > li') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), - date: $(this) - .find('span') - .text() - .slice(1, -1), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), + date: $(this).find('span').text().slice(1, -1), }; return info; }) diff --git a/lib/routes/1x/magazine.js b/lib/routes/1x/magazine.js index 3dc60c22aa..1c35c584af 100644 --- a/lib/routes/1x/magazine.js +++ b/lib/routes/1x/magazine.js @@ -14,9 +14,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(res.data); const unnecessary = ['#navigation', '.Headnote', '.Logotype', '.Footer', '.SplashImage-wrapper', '.Cta', '.CartSidebar', '.bottomNavigation']; batchRemove($, unnecessary); - const list = $('a') - .slice(0, 10) - .get(); + const list = $('a').slice(0, 10).get(); const out = await Promise.all( list.map(async (item) => { const $ = cheerio.load(item); diff --git a/lib/routes/2048/bbs.js b/lib/routes/2048/bbs.js index fc61a791fe..f23a9f1124 100644 --- a/lib/routes/2048/bbs.js +++ b/lib/routes/2048/bbs.js @@ -13,7 +13,7 @@ async function getAvailableHosts(ctx) { const response = await got.get(fby_url); const $ = cheerio.load(response.data); const hosts = $('ul a') - .map(function() { + .map(function () { return $(this).attr('href'); }) .get() @@ -34,9 +34,7 @@ module.exports = async (ctx) => { const list = $('.tr3.t_one').toArray(); $('#breadCrumb span.fr').remove(); - const forum_name = $('#breadCrumb') - .text() - .replace(/»/g, '-'); + const forum_name = $('#breadCrumb').text().replace(/»/g, '-'); const parseContent = async (htmlString) => { const $ = cheerio.load(htmlString); @@ -49,7 +47,7 @@ module.exports = async (ctx) => { pubDate: time ? new Date(time) : new Date(), }; - const test_external_torrent = content.find('a').filter(function() { + const test_external_torrent = content.find('a').filter(function () { return $(this) .attr('href') .match(/\/list\.php\?name=\w{32}/); @@ -72,11 +70,7 @@ module.exports = async (ctx) => { list.slice(0, 30).map(async (item) => { const $ = cheerio.load(item); - if ( - !$('td > a') - .first() - .attr('title') - ) { + if (!$('td > a').first().attr('title')) { return Promise.resolve(''); } diff --git a/lib/routes/21caijing/channel.js b/lib/routes/21caijing/channel.js index 1700d029b1..d3a8a4a02a 100644 --- a/lib/routes/21caijing/channel.js +++ b/lib/routes/21caijing/channel.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { const title = $('h1').text(); const dateStr = $('div.newsDate').text(); - $('div.txtContent img').each(function(index, element) { + $('div.txtContent img').each(function (index, element) { const $el = $(element); const img_original_data = $el.attr('data-original'); const img_src = $el.attr('src'); diff --git a/lib/routes/3dm/game.js b/lib/routes/3dm/game.js index a7e28aecca..5cfc56eef0 100644 --- a/lib/routes/3dm/game.js +++ b/lib/routes/3dm/game.js @@ -18,9 +18,7 @@ module.exports = async (ctx) => { if (type === 'resource') { list = $('.ZQ_Left .Llis_4 .lis:first-of-type li').get(); } else { - list = $('.ZQ_Left .lis') - .slice(0, 10) - .get(); + list = $('.ZQ_Left .lis').slice(0, 10).get(); } const items = list.map((i) => { @@ -37,9 +35,7 @@ module.exports = async (ctx) => { }); ctx.state.data = { - title: $('title') - .text() - .split('_')[0], + title: $('title').text().split('_')[0], link: url, item: items, }; diff --git a/lib/routes/3dm/news_center.js b/lib/routes/3dm/news_center.js index 527fe5ceb6..8902d14347 100644 --- a/lib/routes/3dm/news_center.js +++ b/lib/routes/3dm/news_center.js @@ -13,32 +13,20 @@ module.exports = async (ctx) => { const out = await Promise.all( list.map(async (i) => { const item = $(i); - const itemUrl = $(item) - .find('.text') - .find('a') - .attr('href'); + const itemUrl = $(item).find('.text').find('a').attr('href'); const cache = await ctx.cache.get(itemUrl); if (cache) { return Promise.resolve(JSON.parse(cache)); } - const title = $(item) - .find('.text') - .find('.bt') - .text(); + const title = $(item).find('.text').find('.bt').text(); - const category = $(item) - .find('.text') - .find('.bq') - .find('a') - .text(); + const category = $(item).find('.text').find('.bq').find('a').text(); const itemReponse = await got.get(itemUrl); const itemElement = cheerio.load(itemReponse.data); const description = itemElement('.news_warp_center').html(); - const pageInfo = $(item) - .find('.time') - .text(); + const pageInfo = $(item).find('.time').text(); const regex = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}/; const regRes = regex.exec(pageInfo); const time = regRes === null ? new Date() : new Date(regRes[0]); @@ -59,11 +47,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: - '3DM - ' + - $('title') - .text() - .split('_')[0], + title: '3DM - ' + $('title').text().split('_')[0], link: url, item: out, }; diff --git a/lib/routes/3ycy/home.js b/lib/routes/3ycy/home.js index 7b323f30b3..4bdb67dea9 100644 --- a/lib/routes/3ycy/home.js +++ b/lib/routes/3ycy/home.js @@ -24,10 +24,7 @@ module.exports = async (ctx) => { const link = title.attr('href'); return await ctx.cache.tryGet('3ycy' + link, async () => { - const date = item - .find('div.postSubtitle') - .text() - .trim(); + const date = item.find('div.postSubtitle').text().trim(); const match = /(\d+\/\d+\/\d{4}\s+\d+:\d+:\d+\s*(?:AM|PM))/i.exec(date); const pubDate = match && new Date(match[1] + ' GMT+8').toUTCString(); diff --git a/lib/routes/99percentinvisible/transcript.js b/lib/routes/99percentinvisible/transcript.js index 7d66b7c2f5..dd8274a4fa 100644 --- a/lib/routes/99percentinvisible/transcript.js +++ b/lib/routes/99percentinvisible/transcript.js @@ -27,9 +27,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const single = { - title: $('article header h1') - .text() - .trim(), + title: $('article header h1').text().trim(), link: itemUrl, author: '99% Invisible', description: $('article .page-content').html(), diff --git a/lib/routes/9to5/utils.js b/lib/routes/9to5/utils.js index ab4f78461f..444f2fbdad 100644 --- a/lib/routes/9to5/utils.js +++ b/lib/routes/9to5/utils.js @@ -10,10 +10,7 @@ const ProcessFeed = (data) => { } // remove useless DOMs - content - .find('hr') - .nextAll() - .remove(); + content.find('hr').nextAll().remove(); content.find('hr, ins.adsbygoogle, script').each((i, e) => { $(e).remove(); diff --git a/lib/routes/aeon/category.js b/lib/routes/aeon/category.js index 2dc4b4038e..7bcf506d32 100644 --- a/lib/routes/aeon/category.js +++ b/lib/routes/aeon/category.js @@ -33,14 +33,7 @@ module.exports = async (ctx) => { let bio; const authorInfo = '.article__body__author-details > p:nth-child(2)'; if (capture(authorInfo).html() !== null) { - bio = - `





` + - author.trim() + - ' ' + - capture(authorInfo) - .html() - .trim() + - `


`; + bio = `





` + author.trim() + ' ' + capture(authorInfo).html().trim() + `


`; capture('.article__inline-sidebar').remove(); } else { bio = ''; diff --git a/lib/routes/aisixiang/column.js b/lib/routes/aisixiang/column.js index 57a4af6321..af7b87b6a7 100644 --- a/lib/routes/aisixiang/column.js +++ b/lib/routes/aisixiang/column.js @@ -17,9 +17,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('.search_list > ul > li > a:nth-child(2)') - .slice(0, 10) - .get(); + const list = $('.search_list > ul > li > a:nth-child(2)').slice(0, 10).get(); const columnName = $('.search_list > ul > li:nth-child(1) > a:nth-child(1)').text(); diff --git a/lib/routes/aisixiang/ranking.js b/lib/routes/aisixiang/ranking.js index a5f715c3cf..e34afdbdec 100644 --- a/lib/routes/aisixiang/ranking.js +++ b/lib/routes/aisixiang/ranking.js @@ -17,9 +17,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('.tops_list > .tips > a') - .slice(0, 10) - .get(); + const list = $('.tops_list > .tips > a').slice(0, 10).get(); const columnName = $('.tops_text > h3')[0].firstChild.nodeValue; diff --git a/lib/routes/aisixiang/utils.js b/lib/routes/aisixiang/utils.js index 544f0acc2c..5f87240f29 100644 --- a/lib/routes/aisixiang/utils.js +++ b/lib/routes/aisixiang/utils.js @@ -4,10 +4,7 @@ const got = require('@/utils/got'); const date = require('@/utils/date'); const ProcessFeed = async (link) => { - const id = link - .split('/') - .pop() - .split('.')[0]; + const id = link.split('/').pop().split('.')[0]; let response; response = await got.get(`http://www.aisixiang.com/data/view_json.php?id=${id}`, { @@ -26,13 +23,7 @@ const ProcessFeed = async (link) => { const title = $('.show_text > h3').text(); - const pubDate = date( - $('.show_text > .info') - .text() - .split(':') - .pop(), - 8 - ); + const pubDate = date($('.show_text > .info').text().split(':').pop(), 8); return { title: title.split(':')[1] || title, diff --git a/lib/routes/algocasts/all.js b/lib/routes/algocasts/all.js index fb31efaa23..86b58d0948 100644 --- a/lib/routes/algocasts/all.js +++ b/lib/routes/algocasts/all.js @@ -83,15 +83,10 @@ module.exports = async (ctx) => { $('tr') .slice(1) .each((i, e) => { - const id = $(e) - .find('th') - .text(); + const id = $(e).find('th').text(); const titleLabel = $(e).find('td a'); const title = `${id}. ${titleLabel.text()}`; - const episode = titleLabel - .attr('href') - .trim() - .split('/')[2]; + const episode = titleLabel.attr('href').trim().split('/')[2]; const link = `http://algocasts.io/episodes/${episode}`; infos.push({ id, title, episode, link }); diff --git a/lib/routes/aliyun/database_month.js b/lib/routes/aliyun/database_month.js index d203fc461e..7c1d58d590 100644 --- a/lib/routes/aliyun/database_month.js +++ b/lib/routes/aliyun/database_month.js @@ -9,16 +9,8 @@ module.exports = async (ctx) => { const list = $("ul[class='posts'] > li") .map((i, e) => { const element = $(e); - const title = element - .find('a') - .text() - .trim(); - const link = - 'http://mysql.taobao.org' + - element - .find('a') - .attr('href') - .trim(); + const title = element.find('a').text().trim(); + const link = 'http://mysql.taobao.org' + element.find('a').attr('href').trim(); return { title: title, description: '', diff --git a/lib/routes/aliyun/notice.js b/lib/routes/aliyun/notice.js index 080ebd861e..9d09b6ded5 100644 --- a/lib/routes/aliyun/notice.js +++ b/lib/routes/aliyun/notice.js @@ -25,16 +25,8 @@ module.exports = async (ctx) => { const list = $('ul > li.y-clear') .map((i, e) => { const element = $(e); - const title = element - .find('a') - .text() - .trim(); - const link = - 'https://help.aliyun.com' + - element - .find('a') - .attr('href') - .trim(); + const title = element.find('a').text().trim(); + const link = 'https://help.aliyun.com' + element.find('a').attr('href').trim(); const date = element.find('.y-right').text(); const pubDate = dayjs(`${date} +0800`, 'YYYY-MM-DDHH:mm:ss ZZ'); return { @@ -65,9 +57,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: $('title') - .text() - .trim(), + title: $('title').text().trim(), link: url, item: result, }; diff --git a/lib/routes/allpoetry/order.js b/lib/routes/allpoetry/order.js index c9027f7db1..4ea55b625d 100644 --- a/lib/routes/allpoetry/order.js +++ b/lib/routes/allpoetry/order.js @@ -19,23 +19,15 @@ module.exports = async (ctx) => { const items = $('.sub') .get() .map((e) => { - let itemUrl = $(e) - .find('h1.title > a') - .attr('href'); + let itemUrl = $(e).find('h1.title > a').attr('href'); itemUrl = url.resolve(host, itemUrl); const single = { - title: $(e) - .find('h1.title > a') - .text(), - description: $(e) - .find('div.poem_body') - .html(), + title: $(e).find('h1.title > a').text(), + description: $(e).find('div.poem_body').html(), link: itemUrl, - author: $(e) - .find('div.bio >a ') - .attr('data-name'), + author: $(e).find('div.bio >a ').attr('data-name'), guid: itemUrl, }; diff --git a/lib/routes/andyt/index.js b/lib/routes/andyt/index.js index b505f4e5a5..167e0cce92 100644 --- a/lib/routes/andyt/index.js +++ b/lib/routes/andyt/index.js @@ -26,27 +26,10 @@ module.exports = async (ctx) => { item: $('.bm_c') .find('tbody') .map((index, item) => ({ - title: - `【` + - $(item) - .find('td.by a') - .eq(0) - .text() + - `】` + - $(item) - .find('a.xst') - .text(), + title: `【` + $(item).find('td.by a').eq(0).text() + `】` + $(item).find('a.xst').text(), description: '', - author: $(item) - .find('cite') - .text() - .trim(), - link: - host + - $(item) - .find('a') - .eq(0) - .attr('href'), + author: $(item).find('cite').text().trim(), + link: host + $(item).find('a').eq(0).attr('href'), })) .get(), }; diff --git a/lib/routes/anime1/anime.js b/lib/routes/anime1/anime.js index 1910c207bf..214f10ca2d 100644 --- a/lib/routes/anime1/anime.js +++ b/lib/routes/anime1/anime.js @@ -4,9 +4,7 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const { time, name } = ctx.params; const $ = await got.get(`https://anime1.me/category/${encodeURIComponent(time)}/${encodeURIComponent(name)}`).then((r) => cheerio.load(r.data)); - const title = $('.page-title') - .text() - .trim(); + const title = $('.page-title').text().trim(); ctx.state.data = { title, link: `https://anime1.me/category/${time}/${name}`, diff --git a/lib/routes/anime1/search.js b/lib/routes/anime1/search.js index c218a83725..6b88f8b9db 100644 --- a/lib/routes/anime1/search.js +++ b/lib/routes/anime1/search.js @@ -4,9 +4,7 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const { keyword } = ctx.params; const $ = await got.get(`https://anime1.me/?s=${encodeURIComponent(keyword)}`).then((r) => cheerio.load(r.data)); - const title = $('.page-title') - .text() - .trim(); + const title = $('.page-title').text().trim(); ctx.state.data = { title, link: `https://anime1.me/?s=${keyword}`, diff --git a/lib/routes/animen/news.js b/lib/routes/animen/news.js index d95fef3283..0475ce0bd4 100644 --- a/lib/routes/animen/news.js +++ b/lib/routes/animen/news.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { const response = await got.get(news_detail_api); const details = response.data.news_content.slice(1); - const descriptions = details.map(function(detail) { + const descriptions = details.map(function (detail) { let description; if (detail.news_order_type === 'M') { const id = detail.content.split('=')[1]; diff --git a/lib/routes/anitama/channel.js b/lib/routes/anitama/channel.js index de6c541d88..bb3200e747 100644 --- a/lib/routes/anitama/channel.js +++ b/lib/routes/anitama/channel.js @@ -11,9 +11,7 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(response.data); - const channel_name = $('#area-article-channel .bar') - .text() - .slice(0, -5); + const channel_name = $('#area-article-channel .bar').text().slice(0, -5); const list = $('#area-article-channel div.inner a') .slice(0, 10) .map((i, e) => ({ diff --git a/lib/routes/aozora/newbook.js b/lib/routes/aozora/newbook.js index 20c693dfa4..4c5a3de34f 100644 --- a/lib/routes/aozora/newbook.js +++ b/lib/routes/aozora/newbook.js @@ -31,11 +31,7 @@ module.exports = async (ctx) => { const detail_urls = []; for (let i = 1; i < count + 1; ++i) { // i = 1: first tr is table title, ignore - const link = - base_url + - $(list[i]) - .find('a') - .attr('href'); + const link = base_url + $(list[i]).find('a').attr('href'); detail_urls.push(link); } @@ -56,19 +52,13 @@ module.exports = async (ctx) => { for (let j = 0; j < title_info.length; ++j) { const tmp = he.decode($(title_info[j]).html()); // should convert from escaped to unicode if (tmp.includes('作品名:')) { - title = $(title_info[j]) - .find('td:nth-child(2)') - .text(); + title = $(title_info[j]).find('td:nth-child(2)').text(); } if (tmp.includes('副題:')) { - title_sub = $(title_info[j]) - .find('td:nth-child(2)') - .text(); + title_sub = $(title_info[j]).find('td:nth-child(2)').text(); } if (tmp.includes('著者名:')) { - author = $(title_info[j]) - .find('td:nth-child(2)') - .text(); + author = $(title_info[j]).find('td:nth-child(2)').text(); } } if (title_sub !== '') { diff --git a/lib/routes/apkpure/versions.js b/lib/routes/apkpure/versions.js index d1f0894e29..f108a85c6d 100644 --- a/lib/routes/apkpure/versions.js +++ b/lib/routes/apkpure/versions.js @@ -14,25 +14,10 @@ module.exports = async (ctx) => { item: $('.ver li') .toArray() .map((ver) => ({ - title: $(ver) - .find('.ver-item-n') - .text(), - description: $(ver) - .find('a') - .attr('title'), - link: `https://apkpure.com${decodeURI( - $(ver) - .find('a') - .attr('href') - .split('?from')[0] - )}`, - pubDate: new Date( - $(ver) - .find('.update-on') - .text() - .replace(/年|月/g, '-') - .replace('日', '') - ).toUTCString(), + title: $(ver).find('.ver-item-n').text(), + description: $(ver).find('a').attr('title'), + link: `https://apkpure.com${decodeURI($(ver).find('a').attr('href').split('?from')[0])}`, + pubDate: new Date($(ver).find('.update-on').text().replace(/年|月/g, '-').replace('日', '')).toUTCString(), })), }; }; diff --git a/lib/routes/apnews/topics.js b/lib/routes/apnews/topics.js index 1cc560aa84..66a3c12b2a 100644 --- a/lib/routes/apnews/topics.js +++ b/lib/routes/apnews/topics.js @@ -15,24 +15,15 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); // const list = $('div.FeedCard'); const list = []; - $('div.FeedCard').each(function(index, item) { - if ( - $(item) - .find('a[class^=Component-headline]') - .attr('href') !== undefined - ) { + $('div.FeedCard').each(function (index, item) { + if ($(item).find('a[class^=Component-headline]').attr('href') !== undefined) { list.push(item); } }); const out = await Promise.all( list.map(async (article) => { - const link = url.resolve( - 'https://apnews.com', - $(article) - .find('a[class^=Component-headline]') - .attr('href') - ); + const link = url.resolve('https://apnews.com', $(article).find('a[class^=Component-headline]').attr('href')); const [title, author, pubDate, description] = await ctx.cache.tryGet(link, async () => { const result = await got.get(link); diff --git a/lib/routes/apple/appstore/update.js b/lib/routes/apple/appstore/update.js index ddfef623fb..6330caabc3 100644 --- a/lib/routes/apple/appstore/update.js +++ b/lib/routes/apple/appstore/update.js @@ -17,10 +17,8 @@ module.exports = async (ctx) => { const items = []; if ($('.whats-new').length > 0) { - $('.whats-new').each(function() { - const version = $('.whats-new__latest__version') - .text() - .split(' ')[1]; + $('.whats-new').each(function () { + const version = $('.whats-new__latest__version').text().split(' ')[1]; const date = $('.whats-new__content time').attr('aria-label'); const item = {}; item.title = `${titleTags.text().trim()} ${version}`; diff --git a/lib/routes/apple/exchange_repair.js b/lib/routes/apple/exchange_repair.js index ace4c29845..82098414ca 100644 --- a/lib/routes/apple/exchange_repair.js +++ b/lib/routes/apple/exchange_repair.js @@ -10,9 +10,7 @@ module.exports = async (ctx) => { const response = await got.get(link); const $ = cheerio.load(response.data); - const list = $('section.as-columns') - .get() - .slice(0, 5); + const list = $('section.as-columns').get().slice(0, 5); const out = await Promise.all( list.map(async (item) => { diff --git a/lib/routes/aptonic/action.js b/lib/routes/aptonic/action.js index c93a3a7393..ef98c4ac51 100644 --- a/lib/routes/aptonic/action.js +++ b/lib/routes/aptonic/action.js @@ -20,11 +20,7 @@ module.exports = async (ctx) => { description: `
- ${$(item.find('td')[1]) - .children() - .remove() - .end() - .text()} + ${$(item.find('td')[1]).children().remove().end().text()} `, pubDate: new Date().toUTCString(), link: url.resolve(link, item.find('td.icon a').attr('href')), diff --git a/lib/routes/aqk/vul.js b/lib/routes/aqk/vul.js index f8c80a2a69..2426471533 100644 --- a/lib/routes/aqk/vul.js +++ b/lib/routes/aqk/vul.js @@ -13,16 +13,8 @@ module.exports = async (ctx) => { const title = item.find('td:first-child a').text(); const cve = item.find('td:nth-child(2)').text(); - const pla = item - .find('.vul-type-item') - .text() - .replace(/\s+/g, ''); - const date = new Date( - item - .find('td:nth-last-child(2)') - .text() - .replace(/\s+/g, '') - ).toUTCString(); + const pla = item.find('.vul-type-item').text().replace(/\s+/g, ''); + const date = new Date(item.find('td:nth-last-child(2)').text().replace(/\s+/g, '')).toUTCString(); const href = item.find('a').attr('href'); return { diff --git a/lib/routes/arknights/news.js b/lib/routes/arknights/news.js index 14b226862f..78db0b84fc 100644 --- a/lib/routes/arknights/news.js +++ b/lib/routes/arknights/news.js @@ -16,28 +16,17 @@ module.exports = async (ctx) => { newslist .map(async (index, item) => { const sth = $(item); - const link = `https://ak.hypergryph.com${sth - .find('a') - .attr('href') - .slice(1)}`; + const link = `https://ak.hypergryph.com${sth.find('a').attr('href').slice(1)}`; const description = await ctx.cache.tryGet(link, async () => { const result = await got.get(link); const $ = cheerio.load(result.data); return $('.article-inner').html(); }); return { - title: sth - .find('.news-title') - .first() - .text(), + title: sth.find('.news-title').first().text(), description, link, - pubDate: new Date( - sth - .find('.news-date-text') - .first() - .text() - ), + pubDate: new Date(sth.find('.news-date-text').first().text()), }; }) .get() diff --git a/lib/routes/asahichinese-f/index.js b/lib/routes/asahichinese-f/index.js index b903fbfbcf..f306f58846 100644 --- a/lib/routes/asahichinese-f/index.js +++ b/lib/routes/asahichinese-f/index.js @@ -56,17 +56,11 @@ module.exports = async (ctx) => { const list = $('ul.List li') .slice(1, 11) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), - date: $(this) - .find('span.Date') - .text(), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), + date: $(this).find('span.Date').text(), }; logger.info(info.date); return info; @@ -87,9 +81,7 @@ module.exports = async (ctx) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const description = $('div.ArticleText') - .html() - .trim(); + const description = $('div.ArticleText').html().trim(); const single = { title: title, diff --git a/lib/routes/asahichinese-j/index.js b/lib/routes/asahichinese-j/index.js index cffb6282db..924881d237 100644 --- a/lib/routes/asahichinese-j/index.js +++ b/lib/routes/asahichinese-j/index.js @@ -56,17 +56,11 @@ module.exports = async (ctx) => { const list = $('ul.List li') .slice(1, 11) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), - date: $(this) - .find('span.Date') - .text(), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), + date: $(this).find('span.Date').text(), }; logger.info(info.date); return info; @@ -87,9 +81,7 @@ module.exports = async (ctx) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const description = $('div.ArticleText') - .html() - .trim(); + const description = $('div.ArticleText').html().trim(); const single = { title: title, diff --git a/lib/routes/atfd/index.js b/lib/routes/atfd/index.js index bd937c59a2..8c00eb7203 100644 --- a/lib/routes/atfd/index.js +++ b/lib/routes/atfd/index.js @@ -12,7 +12,7 @@ module.exports = async (ctx) => { let url = 'https://alltheflightdeals.com/deals/locations?origins=['; - locations.split(',').forEach(function(pair) { + locations.split(',').forEach(function (pair) { const country = pair.split('+')[0]; const city = toTitleCase(pair.split('+')[1]); url += `{"country":"${country}","city":"${city}"},`; diff --git a/lib/routes/autotrader/index.js b/lib/routes/autotrader/index.js index b23a0e0c8b..dc35fcf8b5 100644 --- a/lib/routes/autotrader/index.js +++ b/lib/routes/autotrader/index.js @@ -7,9 +7,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data.html); - const idList = $('li.search-page__result') - .slice(0, 10) - .get(); + const idList = $('li.search-page__result').slice(0, 10).get(); const items = await Promise.all( idList.map(async (item) => { @@ -34,11 +32,7 @@ module.exports = async (ctx) => { keyFacts += ''; $('.fpaSpecifications__economy .fpaSpecifications__listItem').each((i, e) => { - keyFacts += `${$(e) - .find('.fpaSpecifications__term') - .text()}: ${$(e) - .find('.fpaSpecifications__description') - .text()}`; + keyFacts += `${$(e).find('.fpaSpecifications__term').text()}: ${$(e).find('.fpaSpecifications__description').text()}`; if ((i + 1) % 4 === 0) { keyFacts += ''; } diff --git a/lib/routes/babykingdom/index.js b/lib/routes/babykingdom/index.js index e5b4ef7afd..54fbd664f1 100644 --- a/lib/routes/babykingdom/index.js +++ b/lib/routes/babykingdom/index.js @@ -28,20 +28,11 @@ module.exports = async (ctx) => { const title = $('h1.xs2 a').text(); const out = $('tbody[id^="normalthread"]') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('td:nth-child(2) > a:nth-child(1)') - .text(), - link: url.resolve( - host, - $(this) - .find('td:nth-child(2) > a:nth-child(1)') - .attr('href') - ), - author: $(this) - .find('td.by.by_author cite a') - .text(), + title: $(this).find('td:nth-child(2) > a:nth-child(1)').text(), + link: url.resolve(host, $(this).find('td:nth-child(2) > a:nth-child(1)').attr('href')), + author: $(this).find('td.by.by_author cite a').text(), }; return info; }) diff --git a/lib/routes/bahamut/utils.js b/lib/routes/bahamut/utils.js index a769ece937..8b1fb3d691 100644 --- a/lib/routes/bahamut/utils.js +++ b/lib/routes/bahamut/utils.js @@ -31,9 +31,7 @@ module.exports = { const title = $('.HOME-mainbox1b > h1 > a'); const link = base + title.attr('href'); const author = $('.HOME-mainbox1b > .ST1 > a').text(); - const time = $('.HOME-mainbox1b > .ST1') - .text() - .split('│')[1]; + const time = $('.HOME-mainbox1b > .ST1').text().split('│')[1]; const cache = await ctx.cache.get(link); if (cache) { diff --git a/lib/routes/bangumi/group/reply.js b/lib/routes/bangumi/group/reply.js index a85801512c..25d3f630fc 100644 --- a/lib/routes/bangumi/group/reply.js +++ b/lib/routes/bangumi/group/reply.js @@ -16,15 +16,7 @@ module.exports = async (ctx) => { id: $el.attr('id'), author: $el.find('.userInfo .l').text(), content: $el.find('.reply_content .message').html(), - date: $el - .children() - .first() - .find('small') - .children() - .remove() - .end() - .text() - .slice(3), + date: $el.children().first().find('small').children().remove().end().text().slice(3), }; }) .get() diff --git a/lib/routes/bangumi/subject/comments.js b/lib/routes/bangumi/subject/comments.js index 777d1cc68d..1885e895f3 100644 --- a/lib/routes/bangumi/subject/comments.js +++ b/lib/routes/bangumi/subject/comments.js @@ -6,9 +6,7 @@ module.exports = async (subjectID, minLength) => { const link = `https://bgm.tv/subject/${subjectID}/comments`; const html = (await got.get(link)).data; const $ = cheerio.load(html); - const title = $('.nameSingle') - .find('a') - .text(); + const title = $('.nameSingle').find('a').text(); const comments = $('.item') .map((i, el) => { const $el = $(el); @@ -18,10 +16,7 @@ module.exports = async (subjectID, minLength) => { rate = $rateEl.attr('class').match(/sstars(\d)/)[1]; } - const dateString = $el - .find('small.grey') - .text() - .slice(2); + const dateString = $el.find('small.grey').text().slice(2); let date; if (dateString.includes('ago')) { // 处理表示相对日期的字符串 diff --git a/lib/routes/banyuetan/index.js b/lib/routes/banyuetan/index.js index bd1ae0a390..98ed8839be 100644 --- a/lib/routes/banyuetan/index.js +++ b/lib/routes/banyuetan/index.js @@ -11,17 +11,11 @@ module.exports = async (ctx) => { const list = $('ul.clearFix li') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h3 a') - .text(), - link: $(this) - .find('h3 a') - .attr('href'), - date: $(this) - .find('span.tag3') - .text(), + title: $(this).find('h3 a').text(), + link: $(this).find('h3 a').attr('href'), + date: $(this).find('span.tag3').text(), }; return info; }) diff --git a/lib/routes/bbc/utils.js b/lib/routes/bbc/utils.js index 70f3e31ae9..ad669dc1c2 100644 --- a/lib/routes/bbc/utils.js +++ b/lib/routes/bbc/utils.js @@ -14,17 +14,13 @@ const ProcessImage = ($, e, c) => { // add image caption const figcaption = $(e).find('.media-caption__text'); if (figcaption.length > 0) { - message += `${$(figcaption[0]) - .text() - .trim()}`; + message += `${$(figcaption[0]).text().trim()}`; } // add image copyright const copyright = $(e).find('.story-image-copyright'); if (copyright.length > 0) { - message += ` ©${$(copyright[0]) - .text() - .trim()}`; + message += ` ©${$(copyright[0]).text().trim()}`; } message += ''; diff --git a/lib/routes/bilibili/blackboard.js b/lib/routes/bilibili/blackboard.js index 32a91d5c5b..42e08a4a2a 100644 --- a/lib/routes/bilibili/blackboard.js +++ b/lib/routes/bilibili/blackboard.js @@ -16,7 +16,7 @@ module.exports = async (ctx) => { link: 'https://www.bilibili.com/blackboard/topic_list.html#/', description: 'bilibili 话题列表', item: data - .filter(function(item, index, array) { + .filter(function (item, index, array) { // 由于某些话题在不同平台上是同时分开发布的,会产生重复,在这里去除 return !index || item.name !== array[index - 1].name; }) diff --git a/lib/routes/bjp/apod.js b/lib/routes/bjp/apod.js index 4f700285f2..1f76b61d7e 100644 --- a/lib/routes/bjp/apod.js +++ b/lib/routes/bjp/apod.js @@ -33,12 +33,7 @@ module.exports = async (ctx) => { const item = { title: $(e).attr('title'), pubDate: new Date($('meta[name=pubDate]').attr('content')).toUTCString(), - description: - image + - content - .find('table') - .last() - .html(), + description: image + content.find('table').last().html(), link, guid: link, }; diff --git a/lib/routes/bjx/huanbao.js b/lib/routes/bjx/huanbao.js index 063c593d9e..45524c0484 100644 --- a/lib/routes/bjx/huanbao.js +++ b/lib/routes/bjx/huanbao.js @@ -69,15 +69,9 @@ async function fetchPage(ctx, link) { const item = { title: $page('.list_detail > h1').text(), description: pages.reduce((desc, $p) => desc + $p('#content').html(), ''), - pubDate: date( - $page('.list_detail .list_copy b') - .last() - .text() - ), + pubDate: date($page('.list_detail .list_copy b').last().text()), link, - author: $page('.list_detail .list_copy b') - .first() - .text(), + author: $page('.list_detail .list_copy b').first().text(), }; ctx.cache.set(link, JSON.stringify(item)); return item; diff --git a/lib/routes/blogread/newest.js b/lib/routes/blogread/newest.js index 4a6482bec4..8e1872b2cc 100644 --- a/lib/routes/blogread/newest.js +++ b/lib/routes/blogread/newest.js @@ -15,15 +15,9 @@ module.exports = async (ctx) => { return { title: $link.text(), - description: elem - .find('dd') - .eq(0) - .text(), + description: elem.find('dd').eq(0).text(), link: $link.attr('href'), - author: elem - .find('.small a') - .eq(0) - .text(), + author: elem.find('.small a').eq(0).text(), }; }) .get(); diff --git a/lib/routes/blogs/diygod/gk.js b/lib/routes/blogs/diygod/gk.js index f9b37903da..9ea40fdc2b 100644 --- a/lib/routes/blogs/diygod/gk.js +++ b/lib/routes/blogs/diygod/gk.js @@ -20,11 +20,7 @@ module.exports = async (ctx) => { list .map((index, item) => { item = $(item); - const title = item - .find('.gk-desc p') - .eq(0) - .text() - .slice(3); + const title = item.find('.gk-desc p').eq(0).text().slice(3); return { title, description: item.html(), diff --git a/lib/routes/blogs/hedwig.js b/lib/routes/blogs/hedwig.js index e8f84b32cc..07d62fd5fa 100644 --- a/lib/routes/blogs/hedwig.js +++ b/lib/routes/blogs/hedwig.js @@ -10,19 +10,14 @@ module.exports = async (ctx) => { url: url, }); const $ = cheerio.load(res.data); - const title = $('div[class="StyledBox-sc-13pk1d4-0 heWGCm"]') - .find('h1') - .text(); + const title = $('div[class="StyledBox-sc-13pk1d4-0 heWGCm"]').find('h1').text(); const list = $('div[class="StyledBox-sc-13pk1d4-0 czKiZd"]') .find('div[class="StyledBox-sc-13pk1d4-0 czKiZd"]') .find('div[class="StyledBox-sc-13pk1d4-0 czKiZd"]') .map((i, e) => { const element = $(e); - const title = element - .find('a') - .find('h3') - .text(); + const title = element.find('a').find('h3').text(); const link = url + element.find('a').attr('href'); return { title: title, @@ -44,9 +39,7 @@ module.exports = async (ctx) => { const itemReponse = await got.get(link); const itemElement = cheerio.load(itemReponse.data); // Remove duplicate title - itemElement('.StyledBox-sc-13pk1d4-0 .bpdfin') - .find('h1[class="StyledHeading-sc-1rdh4aw-0 kIYNxP"]') - .remove(); + itemElement('.StyledBox-sc-13pk1d4-0 .bpdfin').find('h1[class="StyledHeading-sc-1rdh4aw-0 kIYNxP"]').remove(); item.description = itemElement('.StyledBox-sc-13pk1d4-0 .bpdfin').html(); ctx.cache.set(link, JSON.stringify(item)); diff --git a/lib/routes/blogs/wang54.js b/lib/routes/blogs/wang54.js index 4252eca2ec..875d621276 100644 --- a/lib/routes/blogs/wang54.js +++ b/lib/routes/blogs/wang54.js @@ -9,15 +9,9 @@ module.exports = async (ctx) => { const list = $('div.post') .map((i, e) => ({ - title: $(e) - .find('h3 > a') - .text(), - description: $(e) - .find('.post-body') - .html(), - link: $(e) - .find('h3 > a') - .attr('href'), + title: $(e).find('h3 > a').text(), + description: $(e).find('.post-body').html(), + link: $(e).find('h3 > a').attr('href'), author: '王五四', })) .get(); diff --git a/lib/routes/boc/whpj.js b/lib/routes/boc/whpj.js index 3fabfcbd04..f5079bc3c5 100644 --- a/lib/routes/boc/whpj.js +++ b/lib/routes/boc/whpj.js @@ -40,37 +40,21 @@ module.exports = async (ctx) => { const out = $('div.publish table tbody tr') .slice(2) - .map(function() { - const zh_name = $(this) - .find('td:nth-child(1)') - .text(); + .map(function () { + const zh_name = $(this).find('td:nth-child(1)').text(); const en_name = en_names[zh_name] || ''; const name = `${zh_name} ${en_name} `; - const date = `${$(this) - .find('td:nth-child(7)') - .text()} ${$(this) - .find('td:nth-child(8)') - .text()}`; + const date = `${$(this).find('td:nth-child(7)').text()} ${$(this).find('td:nth-child(8)').text()}`; - const xhmr = `现汇买入价:${$(this) - .find('td:nth-child(2)') - .text()}`; + const xhmr = `现汇买入价:${$(this).find('td:nth-child(2)').text()}`; - const xcmr = `现钞买入价:${$(this) - .find('td:nth-child(3)') - .text()}`; + const xcmr = `现钞买入价:${$(this).find('td:nth-child(3)').text()}`; - const xhmc = `现汇卖出价:${$(this) - .find('td:nth-child(4)') - .text()}`; + const xhmc = `现汇卖出价:${$(this).find('td:nth-child(4)').text()}`; - const xcmc = `现钞卖出价:${$(this) - .find('td:nth-child(5)') - .text()}`; + const xcmc = `现钞卖出价:${$(this).find('td:nth-child(5)').text()}`; - const zs = `中行折算价:${$(this) - .find('td:nth-child(6)') - .text()}`; + const zs = `中行折算价:${$(this).find('td:nth-child(6)').text()}`; const content = `${xhmr} ${xcmr} ${xhmc} ${xcmc} ${zs}`; diff --git a/lib/routes/caixin/category.js b/lib/routes/caixin/category.js index f27e58aa36..21e5bbd4fe 100644 --- a/lib/routes/caixin/category.js +++ b/lib/routes/caixin/category.js @@ -21,25 +21,10 @@ module.exports = async (ctx) => { for (let i = 0; i < list.length; i++) { const item = { - title: $(list[i]) - .children('h4') - .children() - .text(), - desc: $(list[i]) - .children('p') - .text(), - pubDate: new Date( - $(list[i]) - .children('span') - .text() - .replace('年', '-') - .replace('月', '-') - .replace('日', '') - ).toUTCString(), - url: $(list[i]) - .children('h4') - .children() - .attr('href'), + title: $(list[i]).children('h4').children().text(), + desc: $(list[i]).children('p').text(), + pubDate: new Date($(list[i]).children('span').text().replace('年', '-').replace('月', '-').replace('日', '')).toUTCString(), + url: $(list[i]).children('h4').children().attr('href'), }; items.push(item); } diff --git a/lib/routes/cartoonmad/comic.js b/lib/routes/cartoonmad/comic.js index 52557af209..9d0e0139be 100644 --- a/lib/routes/cartoonmad/comic.js +++ b/lib/routes/cartoonmad/comic.js @@ -17,9 +17,7 @@ const load = ($, baseUrl) => { }; const getChapters = async (id, $, caches) => { - const chapters = $('#info') - .eq(1) - .find('a'); + const chapters = $('#info').eq(1).find('a'); return await Promise.all( chapters @@ -54,14 +52,8 @@ module.exports = async (ctx) => { const content = iconv.decode(new Buffer.from(data), 'big5'); const $ = cheerio.load(content); - const bookTitle = $('title') - .text() - .match(/\S+/)[0]; - const bookIntro = $('#info') - .eq(0) - .find('td') - .text() - .trim(); + const bookTitle = $('title').text().match(/\S+/)[0]; + const bookIntro = $('#info').eq(0).find('td').text().trim(); // const coverImgSrc = $('.cover') // .parent() // .find('img') diff --git a/lib/routes/cctv/xwlb.js b/lib/routes/cctv/xwlb.js index 48834b4424..91cfd5889e 100644 --- a/lib/routes/cctv/xwlb.js +++ b/lib/routes/cctv/xwlb.js @@ -8,14 +8,7 @@ module.exports = async (ctx) => { const res = await got({ method: 'get', url: 'http://tv.cctv.com/lm/xwlb/' }); const $ = cheerio.load(res.data); // 解析最新一期新闻联播的日期 - const latestDate = dayjs( - date( - $('.md .mh_title > a') - .text() - .replace(/\s/g, '') - ), - { locale: 'zh-cn' } - ); + const latestDate = dayjs(date($('.md .mh_title > a').text().replace(/\s/g, '')), { locale: 'zh-cn' }); const count = []; for (let i = 0; i < 20; i++) { count.push(i); diff --git a/lib/routes/cell/cell/index.js b/lib/routes/cell/cell/index.js index 4b4c7042ca..545426fa06 100644 --- a/lib/routes/cell/cell/index.js +++ b/lib/routes/cell/cell/index.js @@ -20,7 +20,7 @@ module.exports = async (ctx) => { const list = pageCapture('item') .get() - .filter(function(item) { + .filter(function (item) { const $ = cheerio.load(item); const section = $('prism\\:section').text(); @@ -31,13 +31,7 @@ module.exports = async (ctx) => { list.map(async (item) => { const $ = cheerio.load(item); const section = $('prism\\:section').text(); - const address = - alternativeURL + - $('item') - .attr('rdf:about') - .replace('?rss=yes', '') - .split('/') - .pop(); + const address = alternativeURL + $('item').attr('rdf:about').replace('?rss=yes', '').split('/').pop(); const title = $('dc\\:title').text(); const author = $('dc\\:creator').text(); const pubDate = new Date($('dc\\:date').text()).toUTCString(); @@ -49,7 +43,7 @@ module.exports = async (ctx) => { const itemCapture = cheerio.load(itemPage.data); // section + keywords content const keywords = itemCapture('div.keywords-section > div.keyword') - .map(function(i, el) { + .map(function (i, el) { return $(el).text(); }) .get() @@ -63,9 +57,7 @@ module.exports = async (ctx) => { `; // graphical content const brief = $('description').text(); - const graphical = itemCapture('div.abstract.graphical') - .find('img') - .attr('src'); + const graphical = itemCapture('div.abstract.graphical').find('img').attr('src'); let graphicalContents = ''; if (graphical !== '') { graphicalContents = ` diff --git a/lib/routes/cell/cover.js b/lib/routes/cell/cover.js index 7278843365..f255f2b5cc 100644 --- a/lib/routes/cell/cover.js +++ b/lib/routes/cell/cover.js @@ -60,16 +60,13 @@ module.exports = async (ctx) => { const issueDate = $('h1.toc-header__issue-date').text(); const issueNum = $('.toc-header__details span') .contents() - .map(function() { + .map(function () { return this.type === 'text' ? $(this).text() : ''; }) .get() .slice(0, 2) .join(', '); - const issueName = - $('meta[name="name"]') - .attr('content') - .replace('Issue: ', '') || `Cell ...`; + const issueName = $('meta[name="name"]').attr('content').replace('Issue: ', '') || `Cell ...`; const m = $('meta[name="pbContext"]') .attr('content') .match(/issue:issue:pii\\:(S\d{4})(\d{4})(\d{2})(X\d{4})(\w)/); diff --git a/lib/routes/centbrowser/history.js b/lib/routes/centbrowser/history.js index 9350f6a930..702df0a060 100644 --- a/lib/routes/centbrowser/history.js +++ b/lib/routes/centbrowser/history.js @@ -13,10 +13,7 @@ module.exports = async (ctx) => { link: url, item: list.map((update) => { update = $(update); - const version = update - .find('p') - .first() - .attr('id'); + const version = update.find('p').first().attr('id'); const date = update .find('p > i') .text() diff --git a/lib/routes/checkee/index.js b/lib/routes/checkee/index.js index c2e61f969b..1c2d7df949 100644 --- a/lib/routes/checkee/index.js +++ b/lib/routes/checkee/index.js @@ -13,44 +13,18 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const list = $(':nth-child(11) tbody tr') - .map(function() { + .map(function () { return { - id: $(this) - .find(':nth-child(2)') - .text(), - visaType: $(this) - .find(':nth-child(3)') - .text(), - visaEntry: $(this) - .find(':nth-child(4)') - .text(), - usConsulate: $(this) - .find(':nth-child(5)') - .text(), - major: $(this) - .find(':nth-child(6)') - .text(), - status: $(this) - .find(':nth-child(7)') - .text(), - checkDate: $(this) - .find(':nth-child(8)') - .text(), - completeDate: - $(this) - .find(':nth-child(9)') - .text() === '0000-00-00' - ? 'Not Completed' - : $(this) - .find(':nth-child(9)') - .text(), - link: $(this) - .find(':nth-child(11) a') - .attr('href'), - note: - $(this) - .find(':nth-child(11) a') - .attr('title') || '', + id: $(this).find(':nth-child(2)').text(), + visaType: $(this).find(':nth-child(3)').text(), + visaEntry: $(this).find(':nth-child(4)').text(), + usConsulate: $(this).find(':nth-child(5)').text(), + major: $(this).find(':nth-child(6)').text(), + status: $(this).find(':nth-child(7)').text(), + checkDate: $(this).find(':nth-child(8)').text(), + completeDate: $(this).find(':nth-child(9)').text() === '0000-00-00' ? 'Not Completed' : $(this).find(':nth-child(9)').text(), + link: $(this).find(':nth-child(11) a').attr('href'), + note: $(this).find(':nth-child(11) a').attr('title') || '', }; }) .get(); diff --git a/lib/routes/checkra1n/releases.js b/lib/routes/checkra1n/releases.js index c1ee2dd062..28c1b9220e 100644 --- a/lib/routes/checkra1n/releases.js +++ b/lib/routes/checkra1n/releases.js @@ -21,10 +21,7 @@ module.exports = async (ctx) => { const address = 'https://checkra.in' + $item.find('a').attr('href'); return { - title: $item - .find('h3') - .first() - .text(), + title: $item.find('h3').first().text(), description: $item.find('.changelog').html(), link: address, guid: address, diff --git a/lib/routes/chinadaily/english.js b/lib/routes/chinadaily/english.js index 9e1f896435..0c465c98fc 100644 --- a/lib/routes/chinadaily/english.js +++ b/lib/routes/chinadaily/english.js @@ -8,9 +8,7 @@ module.exports = async (ctx) => { const response = await got(url); const $ = cheerio.load(response.data); - const categoryName = $('.CT_title') - .first() - .text(); + const categoryName = $('.CT_title').first().text(); const items = $('.gy_box') .map((_, ele) => { const $item = cheerio.load(ele); diff --git a/lib/routes/chinadialogue/column.js b/lib/routes/chinadialogue/column.js index 30c0064086..6eb20c82cf 100644 --- a/lib/routes/chinadialogue/column.js +++ b/lib/routes/chinadialogue/column.js @@ -30,7 +30,7 @@ module.exports = async (ctx) => { title = []; description = []; - item.find('h1').each(function(index, element) { + item.find('h1').each(function (index, element) { title.push( $(element) .text() @@ -38,7 +38,7 @@ module.exports = async (ctx) => { ); }); - item.find('p').each(function(index, element) { + item.find('p').each(function (index, element) { description.push( $(element) .text() diff --git a/lib/routes/chinadialogue/topics.js b/lib/routes/chinadialogue/topics.js index e2a2ce8a9b..ae5185e302 100644 --- a/lib/routes/chinadialogue/topics.js +++ b/lib/routes/chinadialogue/topics.js @@ -32,7 +32,7 @@ module.exports = async (ctx) => { title = []; description = []; - item.find('h1').each(function(index, element) { + item.find('h1').each(function (index, element) { title.push( $(element) .text() @@ -40,7 +40,7 @@ module.exports = async (ctx) => { ); }); - item.find('p').each(function(index, element) { + item.find('p').each(function (index, element) { description.push($(element).text()); }); diff --git a/lib/routes/chiphell/forum.js b/lib/routes/chiphell/forum.js index d51ca2eccf..cb90379783 100644 --- a/lib/routes/chiphell/forum.js +++ b/lib/routes/chiphell/forum.js @@ -25,12 +25,7 @@ module.exports = async (ctx) => { // replace placeholer image url imgNode.each((index, element) => { - if ( - $(element).attr('src') && - $(element) - .attr('src') - .indexOf('none.gif') !== -1 - ) { + if ($(element).attr('src') && $(element).attr('src').indexOf('none.gif') !== -1) { $(element).attr('src', $(element).attr('zoomfile')); } @@ -40,23 +35,13 @@ module.exports = async (ctx) => { }); // remove image tips - $(description) - .find('div[class*="aimg_tip"]') - .remove(); - $(description) - .find('div[class*="tip"]') - .remove(); - $(description) - .find('p[class="mbn"]') - .remove(); + $(description).find('div[class*="aimg_tip"]').remove(); + $(description).find('div[class*="tip"]').remove(); + $(description).find('p[class="mbn"]').remove(); // remove rate infomation - $(description) - .find('dl[class="rate"]') - .remove(); - $(description) - .find('h3[class*="psth"]') - .remove(); + $(description).find('dl[class="rate"]').remove(); + $(description).find('h3[class*="psth"]').remove(); const single = { title: item.title, diff --git a/lib/routes/chocolatey/software.js b/lib/routes/chocolatey/software.js index 670de40d3d..c8fa4a405d 100644 --- a/lib/routes/chocolatey/software.js +++ b/lib/routes/chocolatey/software.js @@ -24,9 +24,7 @@ function pick_versions(raw_html) { software.version = version; } if (col_index === 0) { - software.software = $(col) - .text() - .trim(); + software.software = $(col).text().trim(); } if (col_index === 2) { software.time = $(col).text(); diff --git a/lib/routes/chrome/extensions.js b/lib/routes/chrome/extensions.js index e5548d314a..6448c136b5 100644 --- a/lib/routes/chrome/extensions.js +++ b/lib/routes/chrome/extensions.js @@ -8,9 +8,7 @@ module.exports = async (ctx) => { method: 'get', url: `https://chrome.google.com/webstore/detail/${id}?hl=en`, }); - const data = cheerio - .load(response.data)('noscript') - .text(); + const data = cheerio.load(response.data)('noscript').text(); const $ = cheerio.load(data); const version = 'v' + $('.h-C-b-p-D-md').text(); diff --git a/lib/routes/ciweimao/chapter.js b/lib/routes/ciweimao/chapter.js index 096e0d8f08..b9cf000948 100644 --- a/lib/routes/ciweimao/chapter.js +++ b/lib/routes/ciweimao/chapter.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const chapter_item = []; - $('.book-chapter>.book-chapter-box>ul>li>a').each(function() { + $('.book-chapter>.book-chapter-box>ul>li>a').each(function () { chapter_item.push({ title: $(this).text(), link: $(this).attr('href'), diff --git a/lib/routes/codeceo/category.js b/lib/routes/codeceo/category.js index 3ab379c75a..4fc07892ed 100644 --- a/lib/routes/codeceo/category.js +++ b/lib/routes/codeceo/category.js @@ -16,9 +16,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); $('.article-entry script').remove(); - $('.article-entry .adsbygoogle') - .parent() - .remove(); + $('.article-entry .adsbygoogle').parent().remove(); return $('.article-entry').html(); }; diff --git a/lib/routes/codeceo/home.js b/lib/routes/codeceo/home.js index 40e69d3a79..cd46c2f80b 100644 --- a/lib/routes/codeceo/home.js +++ b/lib/routes/codeceo/home.js @@ -14,9 +14,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); $('.article-entry script').remove(); - $('.article-entry .adsbygoogle') - .parent() - .remove(); + $('.article-entry .adsbygoogle').parent().remove(); return $('.article-entry').html(); }; diff --git a/lib/routes/coronavirus/sg-moh.js b/lib/routes/coronavirus/sg-moh.js index ebe54bff05..c4e024f84b 100644 --- a/lib/routes/coronavirus/sg-moh.js +++ b/lib/routes/coronavirus/sg-moh.js @@ -14,22 +14,13 @@ module.exports = async (ctx) => { const items = list .filter((_, item) => { item = $(item); - const dateRaw = item - .find('td:first-child') - .text() - .trim(); + const dateRaw = item.find('td:first-child').text().trim(); return dateRaw !== 'Date'; }) .map((_, item) => { item = $(item); - const title = `${item - .find('a') - .first() - .text()}`; - const dateRaw = item - .find('td:first-child') - .text() - .trim(); + const title = `${item.find('a').first().text()}`; + const dateRaw = item.find('td:first-child').text().trim(); const pubDate = Date.parse(dateRaw) && dateRaw; const link = item.find('a').attr('href'); return { diff --git a/lib/routes/csrc/auditstatus.js b/lib/routes/csrc/auditstatus.js index 3e8b5aab13..c762d789b6 100644 --- a/lib/routes/csrc/auditstatus.js +++ b/lib/routes/csrc/auditstatus.js @@ -29,22 +29,12 @@ module.exports = async (ctx) => { const audit_status_td = $('td[style="font-weight:100 ;color: black ;position: relative;left:20px"]'); const audit_status = audit_status_td.eq(-1).text(); const title = '【' + audit_status + '】' + $('li.templateTip').text(); - const audit_date = audit_status_td - .eq(-1) - .next('td') - .text(); + const audit_date = audit_status_td.eq(-1).next('td').text(); let audit_desc = ''; if (audit_status_td.length > 1) { for (let i = 0; i < audit_status_td.length; i++) { - audit_desc += - audit_status_td - .eq(i) - .next('td') - .text() + - ',' + - audit_status_td.eq(i).text() + - ';'; + audit_desc += audit_status_td.eq(i).next('td').text() + ',' + audit_status_td.eq(i).text() + ';'; } } else { audit_desc = audit_date + ',' + audit_status; diff --git a/lib/routes/csrc/fashenwei.js b/lib/routes/csrc/fashenwei.js index 5cf2fd39a2..128c180295 100644 --- a/lib/routes/csrc/fashenwei.js +++ b/lib/routes/csrc/fashenwei.js @@ -13,10 +13,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('li.fbrq').text(); const title = $('li.mc > div').text(); - const sub_url = $('li.mc > div') - .find('a') - .attr('href') - .slice(6); + const sub_url = $('li.mc > div').find('a').attr('href').slice(6); const itemUrl = ori_url + sub_url; const cache = await ctx.cache.get(itemUrl); if (cache) { diff --git a/lib/routes/ctfhub/index.js b/lib/routes/ctfhub/index.js index 2c451504cf..27219aa80b 100644 --- a/lib/routes/ctfhub/index.js +++ b/lib/routes/ctfhub/index.js @@ -49,7 +49,7 @@ module.exports = async (ctx) => { title: 'CTFHub Calendar', link: 'https://www.ctfhub.com/#/calendar', description: '提供全网最全最新的 CTF 赛事信息,关注赛事定制自己专属的比赛日历吧。', - item: data.items.map(function(item) { + item: data.items.map(function (item) { return { title: item.title, description: '', diff --git a/lib/routes/curseforge/generalfiles.js b/lib/routes/curseforge/generalfiles.js index 35d99a1a47..809bd19af8 100644 --- a/lib/routes/curseforge/generalfiles.js +++ b/lib/routes/curseforge/generalfiles.js @@ -20,10 +20,7 @@ module.exports = async (ctx) => { description: 'CurseForge文件更新提醒', item: list .map((i, item) => ({ - title: $(item) - .find('span.table__content.file__name.full') - .text() - .trim(), + title: $(item).find('span.table__content.file__name.full').text().trim(), description: ` @@ -31,30 +28,14 @@ module.exports = async (ctx) => { - - - - + + + +
FileTypeFileSize Download
${$(item) - .find('td.project-file__release-type > span') - .attr('title')}${$(item) - .find('span.table__content.file__name.full') - .text() - .trim()}${$(item) - .find('span.table__content.file__size') - .text() - .trim()}Click Me${$(item).find('td.project-file__release-type > span').attr('title')}${$(item).find('span.table__content.file__name.full').text().trim()}${$(item).find('span.table__content.file__size').text().trim()}Click Me
`, link: filePage, - pubDate: new Date( - 1000 * - $(item) - .find('td.project-file__date-uploaded abbr') - .attr('data-epoch') - ).toUTCString(), + pubDate: new Date(1000 * $(item).find('td.project-file__date-uploaded abbr').attr('data-epoch')).toUTCString(), })) .get(), }; diff --git a/lib/routes/cyzone/author.js b/lib/routes/cyzone/author.js index 30589cdd3d..52dabb89dc 100644 --- a/lib/routes/cyzone/author.js +++ b/lib/routes/cyzone/author.js @@ -29,7 +29,7 @@ module.exports = async (ctx) => { const storyDetail = await got.get(item.link); const data = storyDetail.data; const $ = cheerio.load(data); - $('.article-content img').each(function() { + $('.article-content img').each(function () { const $img = $(this); const src = $img.attr('src'); diff --git a/lib/routes/cyzone/label.js b/lib/routes/cyzone/label.js index 52174a3ed8..6586c98b1d 100644 --- a/lib/routes/cyzone/label.js +++ b/lib/routes/cyzone/label.js @@ -28,7 +28,7 @@ module.exports = async (ctx) => { const storyDetail = await got.get(item.link); const data = storyDetail.data; const $ = cheerio.load(data); - $('.article-content img').each(function() { + $('.article-content img').each(function () { const $img = $(this); const src = $img.attr('src'); diff --git a/lib/routes/d2/daily.js b/lib/routes/d2/daily.js index 31340ebb00..15ce8d7556 100644 --- a/lib/routes/d2/daily.js +++ b/lib/routes/d2/daily.js @@ -9,9 +9,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); // 修改 slice 可以获取更多天的内容,暂时最新的一天就够了 - const days = $('.sidebar-link:contains(年)') - .slice(0, 1) - .toArray(); + const days = $('.sidebar-link:contains(年)').slice(0, 1).toArray(); const items = await Promise.all( days.map(async (ele) => { diff --git a/lib/routes/dapenti/utils.js b/lib/routes/dapenti/utils.js index 25a83e8b10..83d2c2ad4a 100644 --- a/lib/routes/dapenti/utils.js +++ b/lib/routes/dapenti/utils.js @@ -20,9 +20,7 @@ module.exports = { const data = iconv.decode(listRes.data, 'gb2312'); const $ = cheerio.load(data); // 只取最近的三个,取全文rss - const list = $('li', 'ul') - .slice(0, 3) - .get(); + const list = $('li', 'ul').slice(0, 3).get(); const result_item = await Promise.all( list.map(async (item) => { diff --git a/lib/routes/dengekionline/new.js b/lib/routes/dengekionline/new.js index 55d3970173..5b6d04a8b7 100644 --- a/lib/routes/dengekionline/new.js +++ b/lib/routes/dengekionline/new.js @@ -76,9 +76,7 @@ module.exports = async (ctx) => { const liArr = $('li', element); const date = $('time', element).attr('datetime'); - const newLink = $(element) - .attr('href') - .slice(1); + const newLink = $(element).attr('href').slice(1); // 新闻封面 const cover = $('img', element); const category = liArr.map((index, li) => $(li).text()).get(); diff --git a/lib/routes/dianping/user.js b/lib/routes/dianping/user.js index 0d9683a050..9863c69788 100644 --- a/lib/routes/dianping/user.js +++ b/lib/routes/dianping/user.js @@ -5,7 +5,7 @@ function addPictureAndVideo(item) { let content = ''; content += item.pictureList ? item.pictureList - .map(function(ele) { + .map(function (ele) { return ``; }) .join('
') @@ -50,7 +50,7 @@ module.exports = async (ctx) => { 45: '四星半', 50: '五星', }; - const out = data.map(function(item) { + const out = data.map(function (item) { let link = ''; let title = ''; let content = ''; diff --git a/lib/routes/digitaling/article.js b/lib/routes/digitaling/article.js index 2b2239b97f..776e1031d7 100644 --- a/lib/routes/digitaling/article.js +++ b/lib/routes/digitaling/article.js @@ -52,9 +52,7 @@ module.exports = async (ctx) => { const item = { title: $('.clearfix h2').text(), - author: $('#avatar_by') - .find('a') - .text(), + author: $('#avatar_by').find('a').text(), link: itemUrl, description: $('#article_con').html(), pubDate: new Date().toUTCString(), diff --git a/lib/routes/digitaling/index.js b/lib/routes/digitaling/index.js index f6e7b44c93..b82284e001 100644 --- a/lib/routes/digitaling/index.js +++ b/lib/routes/digitaling/index.js @@ -23,9 +23,7 @@ module.exports = async (ctx) => { const item = { title: $('.clearfix h2').text(), - author: $('#avatar_by') - .find('a') - .text(), + author: $('#avatar_by').find('a').text(), link: itemUrl, description: $('#article_con').html(), pubDate: new Date().toUTCString(), diff --git a/lib/routes/digitaling/project.js b/lib/routes/digitaling/project.js index 5120b13b54..4676f9e1b9 100644 --- a/lib/routes/digitaling/project.js +++ b/lib/routes/digitaling/project.js @@ -36,9 +36,7 @@ module.exports = async (ctx) => { const item = { title: $('.clearfix h2').text(), - author: $('#avatar_by') - .find('a') - .text(), + author: $('#avatar_by').find('a').text(), link: itemUrl, description: $('#article_con').html(), pubDate: new Date().toUTCString(), diff --git a/lib/routes/dilidili/fanju.js b/lib/routes/dilidili/fanju.js index 22f4a5f8b8..4cd375ac11 100644 --- a/lib/routes/dilidili/fanju.js +++ b/lib/routes/dilidili/fanju.js @@ -47,11 +47,7 @@ module.exports = async (ctx) => { const beforeFilterList = $('div.swiper-container.xfswiper1 > div > div > ul > li > a').get(); // 获取到剧集列表 const list = []; beforeFilterList.forEach((element) => { - if ( - $(element) - .attr('href') - .indexOf('http://') !== -1 - ) { + if ($(element).attr('href').indexOf('http://') !== -1) { list.push(element); } }); diff --git a/lib/routes/discuz/discuz.js b/lib/routes/discuz/discuz.js index 23a421d1fc..2d91457e1c 100644 --- a/lib/routes/discuz/discuz.js +++ b/lib/routes/discuz/discuz.js @@ -52,9 +52,7 @@ async function load(baseUrl, itemLink, ctx, charset, header) { } const $ = cheerio.load(responseData); // 只抓取论坛1楼消息 - const description = $('div#postlist div[id^=post] td[id^=postmessage]') - .slice(0, 1) - .html(); + const description = $('div#postlist div[id^=post] td[id^=postmessage]').slice(0, 1).html(); ctx.cache.set(itemLink, description); return { description }; } @@ -82,10 +80,7 @@ module.exports = async (ctx) => { let charset = 'utf-8'; for (const attr of contentType.split(';')) { if (attr.indexOf('charset=') >= 0) { - charset = attr - .split('=') - .pop() - .toLowerCase(); + charset = attr.split('=').pop().toLowerCase(); } } const responseData = @@ -111,9 +106,7 @@ module.exports = async (ctx) => { if (version.toUpperCase().startsWith('DISCUZ! 7')) { // discuz 7.x 系列 // 支持全文抓取,限制抓取页面5个 - const list = $('tbody[id^="normalthread"] > tr') - .slice(0, 5) - .get(); + const list = $('tbody[id^="normalthread"] > tr').slice(0, 5).get(); process = await Promise.all( list.map(async (item) => { item = $(item); @@ -130,9 +123,7 @@ module.exports = async (ctx) => { } else if (version.toUpperCase().startsWith('DISCUZ! X')) { // discuz X 系列 // 支持全文抓取,限制抓取页面5个 - const list = $('tbody[id^="normalthread"] > tr') - .slice(0, 5) - .get(); + const list = $('tbody[id^="normalthread"] > tr').slice(0, 5).get(); process = await Promise.all( list.map(async (item) => { item = $(item); @@ -140,12 +131,7 @@ module.exports = async (ctx) => { const single = { title: item.find('a.xst').text(), link: itemLink, - pubDate: dateUtil( - item - .find('td.by:nth-child(3) em span') - .last() - .text() - ), + pubDate: dateUtil(item.find('td.by:nth-child(3) em span').last().text()), }; const detail = await load(link, itemLink, ctx, charset, header); return Promise.resolve(Object.assign({}, single, detail)); diff --git a/lib/routes/docschina/jsweekly.js b/lib/routes/docschina/jsweekly.js index 32c10c4d7b..25ac639999 100644 --- a/lib/routes/docschina/jsweekly.js +++ b/lib/routes/docschina/jsweekly.js @@ -13,13 +13,9 @@ module.exports = async (ctx) => { const $ = cheerio.load(res.data); - const link = $('.sidebar-link') - .eq(1) - .attr('href'); + const link = $('.sidebar-link').eq(1).attr('href'); const title = $('.site-name').text(); - const description = $('a[href="https://javascriptweekly.com/"]') - .parent() - .text(); + const description = $('a[href="https://javascriptweekly.com/"]').parent().text(); const articles = await got({ method: 'get', diff --git a/lib/routes/donews/index.js b/lib/routes/donews/index.js index 63eda79037..0e4e0cb096 100644 --- a/lib/routes/donews/index.js +++ b/lib/routes/donews/index.js @@ -29,28 +29,18 @@ module.exports = async (ctx) => { case '': // 首页轮播 list = $('.focues.hide > ul > li > a').get(); - list = list.concat( - $('.fl.w840 > .block > dl > dd > h3 > a') - .slice(0, 7) - .get() - ); + list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 7).get()); break; case 'ent': case 'idonews': // 首页轮播 list = $('ul.zl-top > li > a').get(); - list = list.concat( - $('.fl.w840 > .block > dl > dd > h3 > a') - .slice(0, 5) - .get() - ); + list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 5).get()); break; default: - list = $('.fl.w840 > .block > dl > dd > h3 > a') - .slice(0, 10) - .get(); + list = $('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 10).get(); break; } diff --git a/lib/routes/dongqiudi/result.js b/lib/routes/dongqiudi/result.js index dcbfefd715..794eee95dd 100644 --- a/lib/routes/dongqiudi/result.js +++ b/lib/routes/dongqiudi/result.js @@ -14,19 +14,13 @@ module.exports = async (ctx) => { for (let i = 0; i < list.length; i++) { const $ = cheerio.load(list[i]); - const score = $('td:nth-of-type(5)') - .text() - .trim(); + const score = $('td:nth-of-type(5)').text().trim(); if (score !== '-') { const time = $('td.match_time_hidden').text(); const type = $('td.gameweek').text(); - const home = $('td:nth-of-type(4)') - .text() - .trim(); - const away = $('td:nth-of-type(6)') - .text() - .trim(); + const home = $('td:nth-of-type(4)').text().trim(); + const away = $('td:nth-of-type(6)').text().trim(); const title = `${type} ${home} ${score} ${away}`; const single = { diff --git a/lib/routes/dongqiudi/special.js b/lib/routes/dongqiudi/special.js index 592da0fce7..c163695265 100644 --- a/lib/routes/dongqiudi/special.js +++ b/lib/routes/dongqiudi/special.js @@ -10,9 +10,7 @@ module.exports = async (ctx) => { const host = 'https://www.dongqiudi.com'; - const list = $('.detail.special ul li h3') - .slice(0, 5) - .get(); + const list = $('.detail.special ul li h3').slice(0, 5).get(); const proList = []; diff --git a/lib/routes/douban/celebrity.js b/lib/routes/douban/celebrity.js index 207a0c5cae..46e9b4c0e8 100644 --- a/lib/routes/douban/celebrity.js +++ b/lib/routes/douban/celebrity.js @@ -31,21 +31,8 @@ module.exports = async (ctx) => { item = $(item); itemPicUrl = item.find('img').attr('src'); return { - title: - '《' + - item.find('h6 > a').text() + - '》' + - item - .find('h6 > span') - .text() - .replace('(', '(') - .replace(')', ')') - .replace('[', '【') - .replace(']', '】'), - description: `
主演:${item - .find('dl > dd') - .last() - .text()}
评分:${item.find('.star > span:nth-child(2)').text()}`, + title: '《' + item.find('h6 > a').text() + '》' + item.find('h6 > span').text().replace('(', '(').replace(')', ')').replace('[', '【').replace(']', '】'), + description: `
主演:${item.find('dl > dd').last().text()}
评分:${item.find('.star > span:nth-child(2)').text()}`, link: item.find('dt > a').attr('href'), }; }) diff --git a/lib/routes/douban/commercialpress/latest.js b/lib/routes/douban/commercialpress/latest.js index 43356d619d..db08eb0c3a 100644 --- a/lib/routes/douban/commercialpress/latest.js +++ b/lib/routes/douban/commercialpress/latest.js @@ -12,10 +12,7 @@ module.exports = async (ctx) => { }); let $ = cheerio.load(roomResponse); const $mod = $('.mod').eq(0); - const title = $mod - .find('.hd > h2 span') - .eq(0) - .text(); + const title = $mod.find('.hd > h2 span').eq(0).text(); const newBookUrl = $mod.find('.pl a').attr('href'); const newBookLandingPage = await got({ @@ -38,7 +35,7 @@ module.exports = async (ctx) => { $ = cheerio.load(newBookPage.data); const resultItem = $('.doulist-item') - .map(function(_, item) { + .map(function (_, item) { const $item = $(item); return { diff --git a/lib/routes/douban/doulist.js b/lib/routes/douban/doulist.js index 002d25a6d2..e7f0056f54 100644 --- a/lib/routes/douban/doulist.js +++ b/lib/routes/douban/doulist.js @@ -11,76 +11,38 @@ module.exports = async (ctx) => { const response = await got.get(link); const $ = cheerio.load(response.data); - const title = $('#content h1') - .text() - .trim(); - const description = $('div.doulist-about') - .text() - .trim(); + const title = $('#content h1').text().trim(); + const description = $('div.doulist-about').text().trim(); const out = $('div.doulist-item') .slice(0, 10) - .map(function() { - const type = $(this) - .find('div.source') - .text() - .trim(); + .map(function () { + const type = $(this).find('div.source').text().trim(); - let title = $(this) - .find('div.bd.doulist-note div.title a') - .text() - .trim(); - let link = $(this) - .find('div.bd.doulist-note div.title a') - .attr('href'); - let description = $(this) - .find('div.bd.doulist-note div.abstract') - .text() - .trim(); + let title = $(this).find('div.bd.doulist-note div.title a').text().trim(); + let link = $(this).find('div.bd.doulist-note div.title a').attr('href'); + let description = $(this).find('div.bd.doulist-note div.abstract').text().trim(); if (type === '来自:豆瓣广播') { - title = $(this) - .find('p.status-content > a') - .text() - .trim(); - link = $(this) - .find('p.status-content a') - .attr('href'); + title = $(this).find('p.status-content > a').text().trim(); + link = $(this).find('p.status-content a').attr('href'); - description = $(this) - .find('span.status-recommend-text') - .text() - .trim(); + description = $(this).find('span.status-recommend-text').text().trim(); } if (type === '来自:豆瓣电影' || type === '来自:豆瓣' || type === '来自:豆瓣读书' || type === '来自:豆瓣音乐') { - title = $(this) - .find('div.bd.doulist-subject div.title a') - .text() - .trim(); - link = $(this) - .find('div.bd.doulist-subject div.title a') - .attr('href'); + title = $(this).find('div.bd.doulist-subject div.title a').text().trim(); + link = $(this).find('div.bd.doulist-subject div.title a').attr('href'); - description = $(this) - .find('div.bd.doulist-subject div.abstract') - .text() - .trim(); + description = $(this).find('div.bd.doulist-subject div.abstract').text().trim(); - const ft = $(this) - .find('div.ft div.comment-item.content') - .text() - .trim(); + const ft = $(this).find('div.ft div.comment-item.content').text().trim(); - const img = $(this) - .find('div.post a img') - .attr('src'); + const img = $(this).find('div.post a img').attr('src'); description = '
' + description + '
' + ft + '
'; } - const date = $(this) - .find('div.ft div.actions time span') - .attr('title'); + const date = $(this).find('div.ft div.actions time span').attr('title'); const single = { title: title, diff --git a/lib/routes/douban/explore.js b/lib/routes/douban/explore.js index 46b2c2383b..7fcf052aaa 100644 --- a/lib/routes/douban/explore.js +++ b/lib/routes/douban/explore.js @@ -23,14 +23,8 @@ module.exports = async (ctx) => { item = $(item); itemPicUrl = `${item.find('a.cover').attr('style')}`.replace('background-image:url(', '').replace(')', ''); return { - title: item - .find('.title a') - .first() - .text(), - description: `作者:${item - .find('.usr-pic a') - .last() - .text()}
描述:${item.find('.content p').text()}
`, + title: item.find('.title a').first().text(), + description: `作者:${item.find('.usr-pic a').last().text()}
描述:${item.find('.content p').text()}
`, link: item.find('.title a').attr('href'), }; }) diff --git a/lib/routes/douban/explore_column.js b/lib/routes/douban/explore_column.js index c7787600c8..8c776ec89e 100644 --- a/lib/routes/douban/explore_column.js +++ b/lib/routes/douban/explore_column.js @@ -12,17 +12,11 @@ module.exports = async (ctx) => { const list = $('div.item') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('div.title a') - .text(), - link: $(this) - .find('div.title a') - .attr('href'), - author: $(this) - .find('div.usr-pic a') - .text(), + title: $(this).find('div.title a').text(), + link: $(this).find('div.title a').attr('href'), + author: $(this).find('div.usr-pic a').text(), }; return info; }) diff --git a/lib/routes/douban/group.js b/lib/routes/douban/group.js index 039c3a6d69..e2452e0b2c 100644 --- a/lib/routes/douban/group.js +++ b/lib/routes/douban/group.js @@ -16,7 +16,7 @@ module.exports = async (ctx) => { let { content } = topic; content = content.replace(/ /g, '
'); - topic.content = content.replace(/<图片(\d*)>/g, function() { + topic.content = content.replace(/<图片(\d*)>/g, function () { try { const photo = photos.filter((p) => p.seq_id === arguments[1]); diff --git a/lib/routes/douban/latest_book.js b/lib/routes/douban/latest_book.js index 1b6c46c4bc..97f28c93c3 100644 --- a/lib/routes/douban/latest_book.js +++ b/lib/routes/douban/latest_book.js @@ -6,21 +6,13 @@ const url = 'https://book.douban.com/latest'; module.exports = async (ctx) => { const res = await got.get(url); const $ = cheerio.load(res.data); - const list = $('#content') - .find('li') - .get(); + const list = $('#content').find('li').get(); ctx.state.data = { title: '豆瓣新书速递', link: url, item: list.map((item, index) => ({ - title: `${index < 20 ? '[虚构类]' : '[非虚构类]'}${$(item) - .find('h2') - .text() - .trim()}`, - link: $(item) - .find('a') - .first() - .attr('href'), + title: `${index < 20 ? '[虚构类]' : '[非虚构类]'}${$(item).find('h2').text().trim()}`, + link: $(item).find('a').first().attr('href'), description: $(item).html(), })), }; diff --git a/lib/routes/douban/latest_music.js b/lib/routes/douban/latest_music.js index db39a84686..6d393c1f2d 100644 --- a/lib/routes/douban/latest_music.js +++ b/lib/routes/douban/latest_music.js @@ -16,12 +16,8 @@ module.exports = async (ctx) => { title, link: url, item: list.map((item) => ({ - title: $(item) - .find('.pl2') - .text(), - link: $(item) - .find('.pl2') - .attr('href'), + title: $(item).find('.pl2').text(), + link: $(item).find('.pl2').attr('href'), description: $(item).html(), })), }; diff --git a/lib/routes/dribbble/utils.js b/lib/routes/dribbble/utils.js index d7c40e1d17..26db77ea04 100644 --- a/lib/routes/dribbble/utils.js +++ b/lib/routes/dribbble/utils.js @@ -47,9 +47,7 @@ async function ProcessFeed(list, caches) { // the rebounds link is used because all other links in the html could // possibly point to /signup/new when loading the site while not logged in. - const itemUrlPath = $('.extras > a') - .attr('href') - .replace('/rebounds', ''); + const itemUrlPath = $('.extras > a').attr('href').replace('/rebounds', ''); const itemUrl = url.resolve(host, itemUrlPath); const team = $('.attribution-team').text() ? ' for ' + $('.attribution-team a.url').text() : ''; diff --git a/lib/routes/dsndsht23/index.js b/lib/routes/dsndsht23/index.js index 361e922c2c..76fb8fcac0 100644 --- a/lib/routes/dsndsht23/index.js +++ b/lib/routes/dsndsht23/index.js @@ -51,24 +51,11 @@ module.exports = async (ctx) => { const list = $('#threadlisttableid tbody[id^=normalthread]') .slice(0, 11) - .map(function() { + .map(function () { const info = { - title: - '[' + - $(this) - .find('th em a') - .text() + - '] ' + - $(this) - .find('a.xst') - .text(), - link: $(this) - .find('a.xst') - .attr('href'), - date: $(this) - .find('td.by') - .find('em span span') - .attr('title'), + title: '[' + $(this).find('th em a').text() + '] ' + $(this).find('a.xst').text(), + link: $(this).find('a.xst').attr('href'), + date: $(this).find('td.by').find('em span span').attr('title'), }; return info; }) diff --git a/lib/routes/dsndsht23/pictures.js b/lib/routes/dsndsht23/pictures.js index 454cf7c607..59a660d9ba 100644 --- a/lib/routes/dsndsht23/pictures.js +++ b/lib/routes/dsndsht23/pictures.js @@ -42,23 +42,16 @@ module.exports = async (ctx) => { const list = $('#threadlisttableid tbody') .slice(1, 21) - .filter(function() { + .filter(function () { // 去除置顶帖子和分割线 const threadID = $(this).attr('id'); return typeof threadID !== 'undefined' && threadID !== 'separatorline' && !threadID.startsWith('stickthread'); }) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a.xst') - .text(), - link: $(this) - .find('a.xst') - .attr('href'), - date: $(this) - .find('td.by') - .find('em span span') - .attr('title'), + title: $(this).find('a.xst').text(), + link: $(this).find('a.xst').attr('href'), + date: $(this).find('td.by').find('em span span').attr('title'), }; return info; }) diff --git a/lib/routes/duozhi/index.js b/lib/routes/duozhi/index.js index 03afd818aa..439f663ac1 100644 --- a/lib/routes/duozhi/index.js +++ b/lib/routes/duozhi/index.js @@ -7,12 +7,8 @@ module.exports = async (ctx) => { const postList = $('.list-post .post-item').get(); const result = await Promise.all( postList.map(async (item) => { - const title = $(item) - .find('.post-title') - .text(); - const link = $(item) - .find('.post-title') - .attr('href'); + const title = $(item).find('.post-title').text(); + const link = $(item).find('.post-title').attr('href'); const guid = link; const single = { @@ -37,13 +33,7 @@ module.exports = async (ctx) => { .find('.subject-content') .html() .replace(/alt="\\"/g, ''); - single.pubDate = new Date( - $(temp.data) - .find('.subject-meta') - .text() - .trim() - .substr(0, 18) - ).toUTCString(); + single.pubDate = new Date($(temp.data).find('.subject-meta').text().trim().substr(0, 18)).toUTCString(); ctx.cache.set(key, { description: single.description, diff --git a/lib/routes/duozhuayu/search.js b/lib/routes/duozhuayu/search.js index 102c206764..de7b276615 100644 --- a/lib/routes/duozhuayu/search.js +++ b/lib/routes/duozhuayu/search.js @@ -7,10 +7,10 @@ module.exports = async (ctx) => { const link = `https://www.duozhuayu.com/search/${wd}`; // token获取见 https://github.com/wong2/userscripts/blob/master/duozhuayu.user.js - const key = 'DkOliWvFNR7C4WvR'.split('').map(function(c) { + const key = 'DkOliWvFNR7C4WvR'.split('').map(function (c) { return c.charCodeAt(); }); - const iv = 'GQWKUE2CVGOOBKXU'.split('').map(function(c) { + const iv = 'GQWKUE2CVGOOBKXU'.split('').map(function (c) { return c.charCodeAt(); }); const aesCfb = new aesjs.ModeOfOperation.cfb(key, iv); diff --git a/lib/routes/dysfz/index.js b/lib/routes/dysfz/index.js index 6410255645..d978537331 100644 --- a/lib/routes/dysfz/index.js +++ b/lib/routes/dysfz/index.js @@ -10,20 +10,10 @@ module.exports = async (ctx) => { link: 'http://www.wuhaozhan.net/movie/list/', description: '高清电影', item: list.map((item) => ({ - title: $(item) - .find('h2') - .text(), - description: $(item) - .find('.l-des') - .text(), - pubDate: new Date( - $(item) - .find('.dt') - .text() - ).toUTCString(), - link: $(item) - .find('.l-a') - .attr('href'), + title: $(item).find('h2').text(), + description: $(item).find('.l-des').text(), + pubDate: new Date($(item).find('.dt').text()).toUTCString(), + link: $(item).find('.l-a').attr('href'), })), }; ctx.state.data = data; diff --git a/lib/routes/dytt/index.js b/lib/routes/dytt/index.js index ff30c7f5a8..43e2848991 100644 --- a/lib/routes/dytt/index.js +++ b/lib/routes/dytt/index.js @@ -43,11 +43,7 @@ module.exports = async (ctx) => { enclosure_type: 'application/x-bittorrent', title: link.text(), description: other, - pubDate: new Date( - $(item) - .find('font') - .text() - ).toUTCString(), + pubDate: new Date($(item).find('font').text()).toUTCString(), link: itemUrl, }; }) diff --git a/lib/routes/eeo/index.js b/lib/routes/eeo/index.js index 59201a9491..3602561964 100644 --- a/lib/routes/eeo/index.js +++ b/lib/routes/eeo/index.js @@ -33,16 +33,10 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const list = $('#lyp_article li').get(); const result = list.map((item) => ({ - title: $(item) - .find('div span a') - .text(), - description: $(item) - .find('div p') - .text(), + title: $(item).find('div span a').text(), + description: $(item).find('div p').text(), pubDate: new Date().toUTCString(), - link: $(item) - .find('>a') - .attr('href'), + link: $(item).find('>a').attr('href'), })); ctx.state.data = { title: '经济观察网', diff --git a/lib/routes/elife/index.js b/lib/routes/elife/index.js index f5b79e6489..8f6a8218c7 100644 --- a/lib/routes/elife/index.js +++ b/lib/routes/elife/index.js @@ -29,9 +29,7 @@ module.exports = async (ctx) => { const address = `${baseUrl}${partial}`; const time = $('time').text(); const description = $('div.teaser__body').text(); - const author = $('div.teaser__secondary_info') - .text() - .trim(); + const author = $('div.teaser__secondary_info').text().trim(); const cache = await ctx.cache.get(address); if (cache) { diff --git a/lib/routes/embassy/index.js b/lib/routes/embassy/index.js index c809ecde97..bf92499ee9 100644 --- a/lib/routes/embassy/index.js +++ b/lib/routes/embassy/index.js @@ -48,12 +48,7 @@ module.exports = async (ctx) => { title: $(config.title).text(), link, description: $(config.description).html(), - pubDate: new Date( - $(config.pubDate) - .text() - .replace('(', '') - .replace(')', '') - ).toUTCString(), + pubDate: new Date($(config.pubDate).text().replace('(', '').replace(')', '')).toUTCString(), }; ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); diff --git a/lib/routes/facebook/page.js b/lib/routes/facebook/page.js index 3d4b6a5f2d..c2f0c3a105 100644 --- a/lib/routes/facebook/page.js +++ b/lib/routes/facebook/page.js @@ -19,9 +19,7 @@ const parseStoryPage = async (linkPath, cache) => { const html = await fetchPageHtml(linkPath, cacheKey, cache); const $ = cheerio.load(html); - const title = $('h3 strong a') - .first() - .text(); + const title = $('h3 strong a').first().text(); const url = `https://www.facebook.com/story.php?story_fbid=${storyFbId}&id=${storyId}`; const $story = $('#m_story_permalink_view').first(); const $content = $story.find('div > div > div > div.cc'); @@ -59,9 +57,7 @@ const parsePhotoPage = async (linkPath, cache) => { const html = await fetchPageHtml(linkPath, cacheKey, cache); const $ = cheerio.load(html); - const title = $('#MPhotoContent div.msg > a > strong') - .first() - .text(); + const title = $('#MPhotoContent div.msg > a > strong').first().text(); const url = `https://www.facebook.com${pathname}`; const $content = $('#MPhotoContent div.msg > div'); $content.find('br').replaceWith('\n'); @@ -86,12 +82,7 @@ module.exports = async (ctx) => { const itemLinks = $('div[role=article] > div:nth-child(2) > div:nth-child(2)') .toArray() - .map((div) => - $(div) - .find('a') - .last() - .attr('href') - ); + .map((div) => $(div).find('a').last().attr('href')); const items = await Promise.all( itemLinks.map(async (itemLink) => { if (new RegExp(`^/.+/photos/`).test(itemLink)) { @@ -126,10 +117,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: $('#m-timeline-cover-section h1 span').text(), link: `https://www.facebook.com/${pageId}`, - description: $('#sub_profile_pic_content>div>div:nth-child(3) div>span') - .find('br') - .replaceWith('\n') - .text(), + description: $('#sub_profile_pic_content>div>div:nth-child(3) div>span').find('br').replaceWith('\n').text(), item: items.filter((item) => !!item), }; }; diff --git a/lib/routes/fanfou/utils.js b/lib/routes/fanfou/utils.js index 8acdf8293e..f868b357d5 100644 --- a/lib/routes/fanfou/utils.js +++ b/lib/routes/fanfou/utils.js @@ -21,7 +21,7 @@ const getFanfou = async () => { password: password, protocol: 'https:', hooks: { - baseString: function(str) { + baseString: function (str) { return str.replace('https', 'http'); }, }, diff --git a/lib/routes/fdroid/apprelease.js b/lib/routes/fdroid/apprelease.js index f866c91993..cc4f167b7d 100644 --- a/lib/routes/fdroid/apprelease.js +++ b/lib/routes/fdroid/apprelease.js @@ -6,46 +6,19 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); - const app_name = $('.package-title') - .find('h3') - .text(); - const app_descr = $('.package-title') - .find('.package-summary') - .text(); + const app_name = $('.package-title').find('h3').text(); + const app_descr = $('.package-title').find('.package-summary').text(); const items = []; $('.package-versions-list') .find('.package-version') - .each(function() { + .each(function () { const item = {}; - const version = $(this) - .find('.package-version-header') - .find('a') - .eq(0) - .attr('name'); + const version = $(this).find('.package-version-header').find('a').eq(0).attr('name'); item.title = version; - item.guid = $(this) - .find('.package-version-header') - .find('a') - .eq(1) - .attr('name'); - item.pubDate = new Date( - $(this) - .find('.package-version-header') - .text() - .split('Added on ')[1] - ).toUTCString(); - item.description = [ - $(this) - .find('.package-version-download') - .html(), - $(this) - .find('.package-version-requirement') - .html(), - $(this) - .find('.package-version-source') - .html(), - ].join('
'); + item.guid = $(this).find('.package-version-header').find('a').eq(1).attr('name'); + item.pubDate = new Date($(this).find('.package-version-header').text().split('Added on ')[1]).toUTCString(); + item.description = [$(this).find('.package-version-download').html(), $(this).find('.package-version-requirement').html(), $(this).find('.package-version-source').html()].join('
'); item.link = `https://f-droid.org/en/packages/${ctx.params.app}/#${version}`; items.push(item); diff --git a/lib/routes/finviz/news.js b/lib/routes/finviz/news.js index c5d5a1d069..c228ec1a81 100644 --- a/lib/routes/finviz/news.js +++ b/lib/routes/finviz/news.js @@ -13,27 +13,17 @@ module.exports = async (ctx) => { const item = await Promise.all( data .map(async (i, e) => { - let date = $(e) - .find('td') - .first() - .text() - .trim(); + let date = $(e).find('td').first().text().trim(); if (date.includes('-')) { dateRow = date.split(' ')[0]; } else { date = `${dateRow} ${date}`; } return { - title: $(e) - .find('a') - .text(), + title: $(e).find('a').text(), pubDate: dateParser(date, 'MMM-DD-YY HH:mmA'), - authors: $(e) - .find('span') - .text(), - link: $(e) - .find('a') - .attr('href'), + authors: $(e).find('span').text(), + link: $(e).find('a').attr('href'), }; }) .get() diff --git a/lib/routes/firefox/addons.js b/lib/routes/firefox/addons.js index 4e76cf2055..15cf355b02 100644 --- a/lib/routes/firefox/addons.js +++ b/lib/routes/firefox/addons.js @@ -8,11 +8,7 @@ module.exports = async (ctx) => { method: 'get', url: `https://addons.mozilla.org/zh-CN/firefox/addon/${id}/versions/`, }); - const data = JSON.parse( - cheerio - .load(response.data)('#redux-store-state') - .html() - ); + const data = JSON.parse(cheerio.load(response.data)('#redux-store-state').html()); const info = data.addons.byID[data.addons.bySlug[id]]; const versionIds = data.versions.bySlug[id].versionIds; diff --git a/lib/routes/flyertea/utils.js b/lib/routes/flyertea/utils.js index 8a0bfe5c85..f045b76a2d 100644 --- a/lib/routes/flyertea/utils.js +++ b/lib/routes/flyertea/utils.js @@ -16,7 +16,7 @@ async function load(link) { $('script').remove(); // 修改图片中的链接 - $('ignore_js_op img').each(function() { + $('ignore_js_op img').each(function () { const new_src = $('ignore_js_op img').attr('file'); $(this).attr('src', new_src); }); diff --git a/lib/routes/galaxylab/index.js b/lib/routes/galaxylab/index.js index edfbfbb442..f727804d74 100644 --- a/lib/routes/galaxylab/index.js +++ b/lib/routes/galaxylab/index.js @@ -24,13 +24,7 @@ module.exports = async (ctx) => { title: item.find('article > a[title]').attr('title'), link: item.find('article > a[title]').attr('href'), description: item.find('article > div.excerpt').text(), - pubDate: new Date( - item - .find('article > div.postinfo > div.left > span.date > b') - .text() - .replace('日', '') - .replace(/\D/g, '-') - ).toUTCString(), + pubDate: new Date(item.find('article > div.postinfo > div.left > span.date > b').text().replace('日', '').replace(/\D/g, '-')).toUTCString(), author: item.find('article > div.postinfo > div.left > span.author > a[title]').attr('title'), }; }) diff --git a/lib/routes/gamersky/ent.js b/lib/routes/gamersky/ent.js index 932c7095a2..f9479bd16a 100644 --- a/lib/routes/gamersky/ent.js +++ b/lib/routes/gamersky/ent.js @@ -26,19 +26,11 @@ module.exports = async (ctx) => { const list = $('ul.pictxt.contentpaging li') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('div.tit a') - .text(), - link: $(this) - .find('div.tit a') - .attr('href'), - pubDate: new Date( - $(this) - .find('.time') - .text() - ).toUTCString(), + title: $(this).find('div.tit a').text(), + link: $(this).find('div.tit a').attr('href'), + pubDate: new Date($(this).find('.time').text()).toUTCString(), }; return info; }) @@ -59,7 +51,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); let next_pages = $('div.page_css a') - .map(function() { + .map(function () { return $(this).attr('href'); }) .get(); @@ -72,9 +64,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); $('div.page_css').remove(); - return $('.Mid2L_con') - .html() - .trim(); + return $('.Mid2L_con').html().trim(); }) ); diff --git a/lib/routes/gamersky/news.js b/lib/routes/gamersky/news.js index 5b4d563204..b0d17c330b 100644 --- a/lib/routes/gamersky/news.js +++ b/lib/routes/gamersky/news.js @@ -15,22 +15,12 @@ module.exports = async (ctx) => { const out = $('.Mid2L_con li') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('.tt') - .text(), - link: $(this) - .find('.tt') - .attr('href'), - pubDate: new Date( - $(this) - .find('.time') - .text() - ).toUTCString(), - description: $(this) - .find('.txt') - .text(), + title: $(this).find('.tt').text(), + link: $(this).find('.tt').attr('href'), + pubDate: new Date($(this).find('.time').text()).toUTCString(), + description: $(this).find('.txt').text(), }; return info; }) diff --git a/lib/routes/gaoqing/utils.js b/lib/routes/gaoqing/utils.js index a3602870b6..fa446a5224 100644 --- a/lib/routes/gaoqing/utils.js +++ b/lib/routes/gaoqing/utils.js @@ -13,9 +13,7 @@ async function load(link) { const img = $('.x-m-poster').html(); // 提取资料 - $('#viewfilm') - .find('img') - .remove(); + $('#viewfilm').find('img').remove(); const info = $('#viewfilm').html(); // 提取简介 diff --git a/lib/routes/gaoqingla/latest.js b/lib/routes/gaoqingla/latest.js index 15b6b38f60..34e73727a9 100644 --- a/lib/routes/gaoqingla/latest.js +++ b/lib/routes/gaoqingla/latest.js @@ -14,9 +14,7 @@ module.exports = async (ctx) => { let result = list .map((_, ele) => { - const coverImg = $(ele) - .find('img') - .attr('src'); + const coverImg = $(ele).find('img').attr('src'); const title = $(ele).attr('title'); return { title, diff --git a/lib/routes/gbcc/trust.js b/lib/routes/gbcc/trust.js index eec3cf0bd8..783b15e43b 100644 --- a/lib/routes/gbcc/trust.js +++ b/lib/routes/gbcc/trust.js @@ -11,9 +11,7 @@ module.exports = async (ctx) => { .map((i, e) => { const text = $(e).next('.entry-text'); return { - title: $(text) - .find('h1') - .html(), + title: $(text).find('h1').html(), link: `${link}#${$(e).children('div')[0].attribs.id}`, description: $(text).html(), pubDate: new Date().toUTCString(), diff --git a/lib/routes/gcores/category.js b/lib/routes/gcores/category.js index 62411d21a9..de144f3d1e 100644 --- a/lib/routes/gcores/category.js +++ b/lib/routes/gcores/category.js @@ -20,17 +20,13 @@ module.exports = async (ctx) => { const out = await Promise.all( count.map(async (i) => { const item = list[i]; - let itemUrl = $(item) - .find('a.am_card_content.original_content') - .attr('href'); + let itemUrl = $(item).find('a.am_card_content.original_content').attr('href'); itemUrl = 'https://www.gcores.com' + itemUrl; const cache = await ctx.cache.get(itemUrl); if (cache) { return Promise.resolve(JSON.parse(cache)); } - const title = $(item) - .find('h3.am_card_title') - .text(); + const title = $(item).find('h3.am_card_title').text(); let itemRes; try { itemRes = await got({ diff --git a/lib/routes/getitfree/utils.js b/lib/routes/getitfree/utils.js index d0cb47dfeb..0354ea1cb3 100644 --- a/lib/routes/getitfree/utils.js +++ b/lib/routes/getitfree/utils.js @@ -15,9 +15,7 @@ const getDeadlineStr = ($, countDownNodeSelector) => { const index = args[args.length - 2]; return index === 10 ? ' ' : index < 10 ? '-' : ':'; }); - deadlineStr = `截至日期: ${dayJs(dateStr) - .locale('zh-cn') - .format('YYYY-MM-DD HH:mm:ss')}`; + deadlineStr = `截至日期: ${dayJs(dateStr).locale('zh-cn').format('YYYY-MM-DD HH:mm:ss')}`; } return deadlineStr; }; @@ -33,9 +31,7 @@ const parseListItem = ($, listSelector) => const pubDate = new Date(pubDateStr).toUTCString(); const thumbnail = $item('.posts-default-img img').attr('data-original'); const deadlineStr = getDeadlineStr($item, '.countDownCont'); - const digest = $item('.posts-default-content > .posts-text') - .text() - .trim(); + const digest = $item('.posts-default-content > .posts-text').text().trim(); return { title, link, diff --git a/lib/routes/gitea/blog.js b/lib/routes/gitea/blog.js index 244c83d84b..27bf7bef44 100644 --- a/lib/routes/gitea/blog.js +++ b/lib/routes/gitea/blog.js @@ -43,17 +43,11 @@ module.exports = async (ctx) => { .get() .map(async (item) => { const title = $('.media .media-content .title', item).text(); - const subtitle = $('.media .media-content .subtitle', item) - .text() - .replace(/\t/g, '') - .replace(/\n/g, ' ') - .trim(); + const subtitle = $('.media .media-content .subtitle', item).text().replace(/\t/g, '').replace(/\n/g, ' ').trim(); const matchs = /(.*) by (.*)/.exec(subtitle); const pubDate = matchs && matchs.length === 3 ? new Date(matchs[1]) : new Date(); const author = matchs && matchs.length === 3 ? matchs[2] : ''; - const link = $(item) - .children('a') - .attr('href'); + const link = $(item).children('a').attr('href'); const desc = await loadContent(link); const single = { diff --git a/lib/routes/github/search.js b/lib/routes/github/search.js index ff6b676d93..14def463f8 100644 --- a/lib/routes/github/search.js +++ b/lib/routes/github/search.js @@ -20,20 +20,11 @@ module.exports = async (ctx) => { const out = $('.repo-list li') .slice(0, 10) - .map(function() { + .map(function () { const single = { - title: $(this) - .find('div h3 a') - .text(), - link: host.concat( - $(this) - .find('div h3 a') - .attr('href') - ), - description: $(this) - .find('div p') - .text() - .trim(), + title: $(this).find('div h3 a').text(), + link: host.concat($(this).find('div h3 a').attr('href')), + description: $(this).find('div p').text().trim(), }; return single; }) diff --git a/lib/routes/github/trending.js b/lib/routes/github/trending.js index 90f31def2f..9a44def32d 100644 --- a/lib/routes/github/trending.js +++ b/lib/routes/github/trending.js @@ -31,14 +31,8 @@ module.exports = async (ctx) => { title: item.find('h1').text(), description: `${item.find('.pr-4').text()}

Language: ${item.find('span[itemprop="programmingLanguage"]').text() || 'unknown'} -
Star: ${item - .find('.muted-link') - .eq(0) - .text()} -
Fork: ${item - .find('.muted-link') - .eq(1) - .text()}`, +
Star: ${item.find('.muted-link').eq(0).text()} +
Fork: ${item.find('.muted-link').eq(1).text()}`, link: `https://github.com${item.find('h1 a').attr('href')}`, }; }) diff --git a/lib/routes/google/citations.js b/lib/routes/google/citations.js index 49bc5354d0..13b0031d33 100644 --- a/lib/routes/google/citations.js +++ b/lib/routes/google/citations.js @@ -14,9 +14,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const profile = $('#gsc_prf .gsc_prf_il') - .eq(0) - .text(); + const profile = $('#gsc_prf .gsc_prf_il').eq(0).text(); const homePage = $('#gsc_prf_ivh a').attr('href'); const name = $('#gsc_prf_in').text(); description += `name: ${name}; profile: ${profile}; homePage: ${homePage}`; @@ -29,12 +27,8 @@ module.exports = async (ctx) => { let itemUrl = $('.gsc_a_t a').attr('data-href'); itemUrl = BASE_URL + itemUrl; - const author = $('.gsc_a_t div') - .eq(0) - .text(); - const publication = $('.gsc_a_t div') - .eq(1) - .text(); + const author = $('.gsc_a_t div').eq(0).text(); + const publication = $('.gsc_a_t div').eq(1).text(); return { title: $('.gsc_a_t a').text(), description: `Author: ${author}; Publication: ${publication}`, diff --git a/lib/routes/google/news.js b/lib/routes/google/news.js index 085143a669..ec305add3d 100644 --- a/lib/routes/google/news.js +++ b/lib/routes/google/news.js @@ -58,25 +58,11 @@ module.exports = async (ctx) => { $(item) .children() .removeAttr('class') - .attr( - 'href', - url.resolve( - 'https://news.google.com', - $(item) - .children() - .attr('href') - ) - ); + .attr('href', url.resolve('https://news.google.com', $(item).children().attr('href'))); }) .toString(); - link = url.resolve( - 'https://news.google.com', - item - .find('a.VDXfz') - .first() - .attr('href') - ); + link = url.resolve('https://news.google.com', item.find('a.VDXfz').first().attr('href')); if (itemPicUrl !== undefined) { description = `${description}`; @@ -86,19 +72,10 @@ module.exports = async (ctx) => { } return { - title: item - .find('h3') - .children() - .text(), + title: item.find('h3').children().text(), description: description, - pubDate: meta - .find('time') - .first() - .attr('datetime'), - author: meta - .find('a.wEwyrc') - .first() - .text(), + pubDate: meta.find('time').first().attr('datetime'), + author: meta.find('a.wEwyrc').first().text(), link: link, }; }) diff --git a/lib/routes/gouhuo/cache.js b/lib/routes/gouhuo/cache.js index 680c130888..7f765aa408 100644 --- a/lib/routes/gouhuo/cache.js +++ b/lib/routes/gouhuo/cache.js @@ -22,14 +22,8 @@ const self = { for (const item of obj.data[0].tabList) { tabNameMapping[item.tab_id] = item.tab_name; } - const title = $('title') - .text() - .split('-')[0] - .trim(); - const description = $('title') - .text() - .split('-')[1] - .trim(); + const title = $('title').text().split('-')[0].trim(); + const description = $('title').text().split('-')[1].trim(); profile = JSON.stringify({ title: title, diff --git a/lib/routes/gouhuo/strategy.js b/lib/routes/gouhuo/strategy.js index d7c5305353..f5897ebf77 100644 --- a/lib/routes/gouhuo/strategy.js +++ b/lib/routes/gouhuo/strategy.js @@ -28,9 +28,7 @@ module.exports = async (ctx) => { }); ctx.state.data = { - title: $('title') - .text() - .split('_')[0], + title: $('title').text().split('_')[0], link: url, item: items, }; diff --git a/lib/routes/gov/customs/list.js b/lib/routes/gov/customs/list.js index b58fb9ce0f..b6688802c6 100644 --- a/lib/routes/gov/customs/list.js +++ b/lib/routes/gov/customs/list.js @@ -30,17 +30,11 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const list = $('[class^="conList_ul"] li') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), - date: $(this) - .find('span') - .text(), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), + date: $(this).find('span').text(), }; return info; }) diff --git a/lib/routes/gov/hunan/notice.js b/lib/routes/gov/hunan/notice.js index 4382555bef..232af4cb65 100644 --- a/lib/routes/gov/hunan/notice.js +++ b/lib/routes/gov/hunan/notice.js @@ -17,10 +17,10 @@ module.exports = async (ctx) => { ['zz', { name: '终止公告', id: 'endNotices' }], ['qt', { name: '其他公告', id: 'otherNotices' }], ]), - typeName: function(type) { + typeName: function (type) { return rssData.Category.get(type).name; }, - typeid: function(type) { + typeid: function (type) { return rssData.Category.get(type).id; }, ProcessFeed: async (id) => { @@ -34,7 +34,7 @@ module.exports = async (ctx) => { const htmlContent = response.data; return htmlContent; }, - ItemsSingle: async function(item) { + ItemsSingle: async function (item) { const cache = await ctx.cache.get(rssData.itemUrl + item.NOTICE_ID); if (cache) { return Promise.resolve(JSON.parse(cache)); diff --git a/lib/routes/gov/province/jiangsu/getContent.js b/lib/routes/gov/province/jiangsu/getContent.js index f4455f91ae..9a8a5680ec 100644 --- a/lib/routes/gov/province/jiangsu/getContent.js +++ b/lib/routes/gov/province/jiangsu/getContent.js @@ -66,9 +66,7 @@ async function extract(homePage, cid, uid, page = 1) { if (page === 1) { const title = $('head title'); - const [name, category] = $(title) - .text() - .split(' '); + const [name, category] = $(title).text().split(' '); return { title: category, description: `${category} - ${name}`, diff --git a/lib/routes/gov/sapprft/7026.js b/lib/routes/gov/sapprft/7026.js index a5972004b7..fbcf505bbc 100644 --- a/lib/routes/gov/sapprft/7026.js +++ b/lib/routes/gov/sapprft/7026.js @@ -52,10 +52,7 @@ module.exports = async (ctx) => { .slice(1) .each((index, item) => { item = $$(item).find('td'); - fullTextData += - $$(item[0]) - .text() - .trim() + ' | '; + fullTextData += $$(item[0]).text().trim() + ' | '; }); fullTextData = '| ' + fullTextData; return fullTextData; @@ -84,31 +81,12 @@ module.exports = async (ctx) => { .map(async (index, item) => { item = $$(item).find('td'); return { - title: $$(item[0]) - .text() - .trim(), - category: $$(item[1]) - .text() - .trim(), - description: $$(item[4]) - .text() - .trim(), - author: - $$(item[2]) - .text() - .trim() + - ' | ' + - $$(item[3]) - .text() - .trim(), - pubDate: date( - $$(item[6]) - .text() - .trim() - ), - guid: $$(item[5]) - .text() - .trim(), + title: $$(item[0]).text().trim(), + category: $$(item[1]).text().trim(), + description: $$(item[4]).text().trim(), + author: $$(item[2]).text().trim() + ' | ' + $$(item[3]).text().trim(), + pubDate: date($$(item[6]).text().trim()), + guid: $$(item[5]).text().trim(), link: url, }; }) diff --git a/lib/routes/gov/suzhou/doc.js b/lib/routes/gov/suzhou/doc.js index c3c8ab6bef..33ed8397f2 100644 --- a/lib/routes/gov/suzhou/doc.js +++ b/lib/routes/gov/suzhou/doc.js @@ -22,9 +22,7 @@ module.exports = async (ctx) => { const fullText = await got.get(contentUrl); const fullTextData = cheerio.load(fullText.data); const description = fullTextData('.content').html(); - const title = fullTextData('.title.bold') - .text() - .replace(/\s*/g, ''); + const title = fullTextData('.title.bold').text().replace(/\s*/g, ''); return new Array(title, description); }); return { diff --git a/lib/routes/gov/suzhou/news.js b/lib/routes/gov/suzhou/news.js index c05fc638d0..e5d4556f77 100644 --- a/lib/routes/gov/suzhou/news.js +++ b/lib/routes/gov/suzhou/news.js @@ -95,12 +95,7 @@ module.exports = async (ctx) => { title: a.text(), description: description, link: link, - pubDate: new Date( - item - .find('span') - .text() - .trim() + ' GMT+8' - ).toUTCString(), + pubDate: new Date(item.find('span').text().trim() + ' GMT+8').toUTCString(), }; }) .get() diff --git a/lib/routes/gracg/user.js b/lib/routes/gracg/user.js index 46d64ea14f..97c4375d37 100644 --- a/lib/routes/gracg/user.js +++ b/lib/routes/gracg/user.js @@ -23,9 +23,7 @@ module.exports = async (ctx) => { data .slice(0, 10) .map(async (i, el) => { - const link = $(el) - .find('.imgbox a') - .attr('href'); + const link = $(el).find('.imgbox a').attr('href'); const pics = await ctx.cache.tryGet(link, async () => { const res = await got.get(link); const $1 = cheerio.load(res.body); @@ -35,15 +33,9 @@ module.exports = async (ctx) => { }); const description = generateItemDesc(pics); return { - title: $(el) - .find('.infobox .titles') - .text(), + title: $(el).find('.infobox .titles').text(), description, - pubDate: new Date( - $(el) - .find('.infobox .time') - .text() - ).toUTCString(), + pubDate: new Date($(el).find('.infobox .time').text()).toUTCString(), link, }; }) diff --git a/lib/routes/gradcafe/result.js b/lib/routes/gradcafe/result.js index e3db9d684b..b517fc6179 100644 --- a/lib/routes/gradcafe/result.js +++ b/lib/routes/gradcafe/result.js @@ -13,24 +13,11 @@ module.exports = async (ctx) => { const list = $('table.submission-table tbody tr'); const out = list .slice(0, 10) - .map(function() { - const title = $(this) - .find('.tcol1 ') - .text(); - const author = $(this) - .find('.tcol2') - .text(); - const description = - $(this) - .find($('strong').parents('.tcol3')) - .text() + - ' Note:' + - $(this) - .find('.tcol6') - .text(); - const pubDate = $(this) - .find('.tcol5') - .text(); + .map(function () { + const title = $(this).find('.tcol1 ').text(); + const author = $(this).find('.tcol2').text(); + const description = $(this).find($('strong').parents('.tcol3')).text() + ' Note:' + $(this).find('.tcol6').text(); + const pubDate = $(this).find('.tcol5').text(); const item = { title, author, diff --git a/lib/routes/greasyfork/scripts.js b/lib/routes/greasyfork/scripts.js index ade5478d77..9c46434c85 100644 --- a/lib/routes/greasyfork/scripts.js +++ b/lib/routes/greasyfork/scripts.js @@ -20,9 +20,7 @@ module.exports = async (ctx) => { const list = $('.script-list').find('h2'); ctx.state.data = { - title: $('title') - .first() - .text(), + title: $('title').first().text(), link: `https://greasyfork.org/${language}/scripts/${url}`, description: $('meta[name=description]').attr('content'), item: diff --git a/lib/routes/guanchazhe/index.js b/lib/routes/guanchazhe/index.js index cee1fb001d..0cead0300f 100644 --- a/lib/routes/guanchazhe/index.js +++ b/lib/routes/guanchazhe/index.js @@ -22,9 +22,7 @@ module.exports = async (ctx) => { function getData(jscontent, option) { switch (option) { case 'date': { - const jsoutput = String(jscontent) - .substr(-23, 10) - .replace(/_/g, '-'); + const jsoutput = String(jscontent).substr(-23, 10).replace(/_/g, '-'); return new Date(jsoutput).toLocaleDateString(); } case 'urlid': { @@ -58,15 +56,9 @@ module.exports = async (ctx) => { htmlarr[0] = $('.content-headline').first(); htmlarr[1] = $('.Review-item li h4').parent(); htmlarr[2] = $('.img-List li h4').parent(); - $('.author-intro img') - .parent() - .remove(); - $('.module-img-head img') - .parent() - .remove(); - htmlarr[3] = $('[class="module-news gray"] .module-news-main') - .first() - .children(); + $('.author-intro img').parent().remove(); + $('.module-img-head img').parent().remove(); + htmlarr[3] = $('[class="module-news gray"] .module-news-main').first().children(); htmlarr[4] = $('[class="module-news-main mt15"]').children(); temp.length = 0; temp.push( @@ -76,24 +68,10 @@ module.exports = async (ctx) => { const feed = { category: ptype[key].name + '头条', id: getData(herfString, 'urlid'), - title: item - .find('h3') - .text() - .trim(), + title: item.find('h3').text().trim(), pageurl: host + herfString, - picurl: item - .find('a>img') - .first() - .attr('src'), - description: - item - .find('h3') - .text() - .trim() + - ``, + picurl: item.find('a>img').first().attr('src'), + description: item.find('h3').text().trim() + ``, date: getData(herfString, 'date'), }; return feed; @@ -106,17 +84,11 @@ module.exports = async (ctx) => { const feed = { category: ptype[key].name + '左1列', id: getData(herfString, 'urlid'), - title: item - .find('h4.module-title') - .text() - .trim(), + title: item.find('h4.module-title').text().trim(), pageurl: host + herfString, picurl: item.find('a.module-img>img').attr('src'), description: - item - .find('p.module-artile') - .text() - .trim() + + item.find('p.module-artile').text().trim() + `

【全文阅读】
`, @@ -132,10 +104,7 @@ module.exports = async (ctx) => { const feed = { category: ptype[key].name + '中间+右边2列', id: getData(herfString, 'urlid'), - title: item - .find('h4.module-title') - .text() - .trim(), + title: item.find('h4.module-title').text().trim(), pageurl: item.find('div.fastRead-img a>img').attr('src'), picurl: item.find('a>img').attr('src'), description: @@ -151,29 +120,14 @@ module.exports = async (ctx) => { temp.push( htmlarr[3].map((index, item) => { item = $(item); - const herfString = item - .find('a') - .first() - .attr('href'); + const herfString = item.find('a').first().attr('href'); const feed = { category: ptype[key].name + '左列: 访谈、论坛', id: getData(herfString, 'urlid'), - title: item - .find('a') - .first() - .text(), + title: item.find('a').first().text(), pageurl: host + herfString, picurl: `0`, - description: - item - .find('a') - .first() - .text() + - item - .find('p') - .first() - .text() + - `

【全文阅读】
`, + description: item.find('a').first().text() + item.find('p').first().text() + `

【全文阅读】
`, date: getData(herfString, 'date'), }; return feed; @@ -182,24 +136,14 @@ module.exports = async (ctx) => { temp.push( htmlarr[4].map((index, item) => { item = $(item); - const herfString = item - .find('a') - .first() - .attr('href'); + const herfString = item.find('a').first().attr('href'); const feed = { category: ptype[key].name + '右列: 历史、深度', id: getData(herfString, 'urlid'), - title: item - .find('a') - .first() - .text(), + title: item.find('a').first().text(), pageurl: host + herfString, picurl: `0`, - description: - item - .find('a') - .first() - .text() + `

【全文阅读】
`, + description: item.find('a').first().text() + `

【全文阅读】
`, date: getData(herfString, 'date'), }; return feed; diff --git a/lib/routes/guanchazhe/topic.js b/lib/routes/guanchazhe/topic.js index cd872a660b..94924cdb28 100644 --- a/lib/routes/guanchazhe/topic.js +++ b/lib/routes/guanchazhe/topic.js @@ -33,10 +33,7 @@ module.exports = async (ctx) => { const dateStr = $('.user-main .time1').text(); const item = { title: $('.article-content h1').text(), - author: $('.user-main h4') - .first() - .find('a') - .text(), + author: $('.user-main h4').first().find('a').text(), link: absoluteUrl, description: $('.article-txt-content').html(), // 格式化日期 diff --git a/lib/routes/guardian/utils.js b/lib/routes/guardian/utils.js index 744feb0d29..857c850374 100644 --- a/lib/routes/guardian/utils.js +++ b/lib/routes/guardian/utils.js @@ -17,9 +17,7 @@ const ProcessFeed = (data) => { const pic = $(e).find('img'); let rpic = `
${pic[0].attribs.alt}
`; const rcaption = $(e).find('figcaption'); - rpic += `${$(rcaption[0]) - .text() - .trim()}
`; + rpic += `${$(rcaption[0]).text().trim()}`; $(e).replaceWith(rpic); }); @@ -31,9 +29,7 @@ const ProcessFeed = (data) => { const caption = $('#img-1').find('figcaption'); - cover += `${$(caption[0]) - .text() - .trim()}`; + cover += `${$(caption[0]).text().trim()}`; $(cover).insertBefore(content[0].firstChild); } diff --git a/lib/routes/guat/news.js b/lib/routes/guat/news.js index 62758a15a8..91a2c50f5b 100644 --- a/lib/routes/guat/news.js +++ b/lib/routes/guat/news.js @@ -50,15 +50,8 @@ module.exports = async (ctx) => { // 适应桂航的奇葩规则 for (let index = 0; index < 19; index++) { const element = $(`#line_u8_${index}`); - const item_title = element - .find('a') - .first() - .text(); - const item_link = element - .find('a') - .first() - .attr('href') - .replace('../', host); + const item_title = element.find('a').first().text(); + const item_link = element.find('a').first().attr('href').replace('../', host); list.push({ title: item_title, diff --git a/lib/routes/gushiwen/recommend.js b/lib/routes/gushiwen/recommend.js index 070a6ffdd8..e48d3905c5 100644 --- a/lib/routes/gushiwen/recommend.js +++ b/lib/routes/gushiwen/recommend.js @@ -9,19 +9,11 @@ module.exports = async (ctx) => { const list = $('div.sons'); const out = list .slice(0, 10) - .map(function() { - const title = $(this) - .find('b') - .text(); - const link = $(this) - .find('p a') - .attr('href'); - const description = $(this) - .find('div.contson') - .html(); - const author = $(this) - .find('p.source') - .text(); + .map(function () { + const title = $(this).find('b').text(); + const link = $(this).find('p a').attr('href'); + const description = $(this).find('div.contson').html(); + const author = $(this).find('p.source').text(); const item = { title, link, diff --git a/lib/routes/hackernews/story.js b/lib/routes/hackernews/story.js index ad5f8e410d..9172308570 100644 --- a/lib/routes/hackernews/story.js +++ b/lib/routes/hackernews/story.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const items = $('a.storylink') - .map(function() { + .map(function () { return { title: $(this).text(), link: $(this).attr('href'), @@ -31,11 +31,11 @@ module.exports = async (ctx) => { }) .get(); - $('a.hnuser').each(function(i) { + $('a.hnuser').each(function (i) { items[i].author = $(this).text(); }); - $('tr.athing').each(function(i) { + $('tr.athing').each(function (i) { const commURL = `${host}/item?id=` + $(this).attr('id'); const item = items[i]; diff --git a/lib/routes/haimaoba/comics.js b/lib/routes/haimaoba/comics.js index c64f9fe8c0..40b2d1b102 100644 --- a/lib/routes/haimaoba/comics.js +++ b/lib/routes/haimaoba/comics.js @@ -5,15 +5,7 @@ const iconv = require('iconv-lite'); const getChapters = async (id, $, caches) => { const chapters = $('.text') .toArray() - .reduce( - (acc, curr) => - acc.concat( - `http://www.haimaoba.com${$(curr) - .children('a') - .attr('href')}` - ), - [] - ); + .reduce((acc, curr) => acc.concat(`http://www.haimaoba.com${$(curr).children('a').attr('href')}`), []); return await Promise.all( chapters.splice(0, 10).map( diff --git a/lib/routes/hatena/anonymous_diary/archive.js b/lib/routes/hatena/anonymous_diary/archive.js index e86e687df3..f542b35edd 100644 --- a/lib/routes/hatena/anonymous_diary/archive.js +++ b/lib/routes/hatena/anonymous_diary/archive.js @@ -20,13 +20,7 @@ module.exports = async (ctx) => { url: url.resolve(baseURL, '/archive'), }); - const latestURL = url.resolve( - baseURL, - cheerio - .load(archiveIndex.data)('.archives a') - .first() - .attr('href') - ); + const latestURL = url.resolve(baseURL, cheerio.load(archiveIndex.data)('.archives a').first().attr('href')); const response = await got({ method: 'get', url: latestURL, @@ -48,10 +42,7 @@ module.exports = async (ctx) => { const yyyyMMddhhmmss = a.attr('href').replace('/', ''); return { title: a.text(), - description: item - .find('blockquote p') - .first() - .text(), + description: item.find('blockquote p').first().text(), link: url.resolve(baseURL, a.attr('href')), pubDate: getPubDate(yyyyMMddhhmmss).toUTCString(), }; diff --git a/lib/routes/hinatazaka46/blog.js b/lib/routes/hinatazaka46/blog.js index f7bde202da..eaed2d9f7f 100644 --- a/lib/routes/hinatazaka46/blog.js +++ b/lib/routes/hinatazaka46/blog.js @@ -26,19 +26,10 @@ module.exports = async (ctx) => { item = $(item); itemPicUrl = `${item.find('div.c-blog__image').attr('style')}`.replace('background-image:url(', '').replace(');', ''); return { - title: item - .find('p.c-blog-top__title') - .text() - .trim(), - link: item - .find('a') - .first() - .attr('href'), + title: item.find('p.c-blog-top__title').text().trim(), + link: item.find('a').first().attr('href'), pubDate: item.find('time.c-blog-top__date').text(), - author: item - .find('div.c-blog-top__name') - .text() - .trim(), + author: item.find('div.c-blog-top__name').text().trim(), description: ``, }; }) diff --git a/lib/routes/hinatazaka46/news.js b/lib/routes/hinatazaka46/news.js index d058c7cbba..7566111ab3 100644 --- a/lib/routes/hinatazaka46/news.js +++ b/lib/routes/hinatazaka46/news.js @@ -24,15 +24,9 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: item - .find('a p.c-news__text') - .first() - .text(), + title: item.find('a p.c-news__text').first().text(), link: item.find('a').attr('href'), - pubDate: item - .find('a time.c-news__date') - .first() - .text(), + pubDate: item.find('a time.c-news__date').first().text(), }; }) .get(), diff --git a/lib/routes/hko/weather.js b/lib/routes/hko/weather.js index 0feb12586c..0da1cf41fa 100644 --- a/lib/routes/hko/weather.js +++ b/lib/routes/hko/weather.js @@ -12,23 +12,18 @@ module.exports = async (ctx) => { const $ = cheerio.load(data, { xmlMode: true, }); - const weather = $('description') - .slice(1, 2) - .text(); + const weather = $('description').slice(1, 2).text(); const $$ = cheerio.load(weather); const items = []; $$('table') .find('td') - .each(function(index, element) { + .each(function (index, element) { if (index % 2) { return; } const area = $$(element).text(); - const degree = $$(element) - .next() - .text() - .split(' ')[0]; + const degree = $$(element).next().text().split(' ')[0]; const item = { title: area, diff --git a/lib/routes/hopper/index.js b/lib/routes/hopper/index.js index e91a662083..990f6da351 100644 --- a/lib/routes/hopper/index.js +++ b/lib/routes/hopper/index.js @@ -31,12 +31,7 @@ module.exports = async (ctx) => { let lowIndex = 0; list.each((i, e) => { - const current = parseInt( - $(e) - .find('.price') - .text() - .replace(/\D/g, '') - ); + const current = parseInt($(e).find('.price').text().replace(/\D/g, '')); if (current < lowest) { lowest = current; diff --git a/lib/routes/houxu/events.js b/lib/routes/houxu/events.js index be71022fd7..0d669e871f 100644 --- a/lib/routes/houxu/events.js +++ b/lib/routes/houxu/events.js @@ -12,37 +12,15 @@ module.exports = async (ctx) => { .map((_, el) => { const each = $(el); return { - title: - each - .find('a') - .first() - .text() - .trim() + - ' | ' + - each - .find('h3') - .text() - .trim(), - description: each - .find(descriptionSelector) - .text() - .trim(), - link: - 'https://houxu.app' + - each - .find('a') - .first() - .attr('href'), + title: each.find('a').first().text().trim() + ' | ' + each.find('h3').text().trim(), + description: each.find(descriptionSelector).text().trim(), + link: 'https://houxu.app' + each.find('a').first().attr('href'), }; }) .get(); ctx.state.data = { - title: $('title') - .text() - .trim(), - description: $('title') - .text() - .trim(), + title: $('title').text().trim(), + description: $('title').text().trim(), link: baseUrl, item: out, }; diff --git a/lib/routes/hpoi/index.js b/lib/routes/hpoi/index.js index f0bb36fe02..662b91e44d 100644 --- a/lib/routes/hpoi/index.js +++ b/lib/routes/hpoi/index.js @@ -27,12 +27,7 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(response.data); ctx.state.data = { - title: - 'Hpoi 手办维基' + - ' - ' + - $(`#${category}`) - .text() - .trim(), + title: 'Hpoi 手办维基' + ' - ' + $(`#${category}`).text().trim(), link: link, item: $('.bs-glyphicons-list .detail-grid') .map((_index, _item) => { @@ -40,13 +35,7 @@ module.exports = async (ctx) => { return { title: _item.find('.detail-grid-title').text(), link: host + '/' + _item.find('.detail-grid-title a').attr('href'), - description: `${_item - .find('.detail-grid-info span') - .eq(0) - .text()}
${_item - .find('.detail-grid-info span') - .eq(1) - .text()}
${_item + description: `${_item.find('.detail-grid-info span').eq(0).text()}
${_item.find('.detail-grid-info span').eq(1).text()}
${_item .find('.detail-grid-info span') .eq(2) .text()}`, diff --git a/lib/routes/hpoi/info.js b/lib/routes/hpoi/info.js index 6d3c4f6f72..544f5c67d7 100644 --- a/lib/routes/hpoi/info.js +++ b/lib/routes/hpoi/info.js @@ -18,18 +18,9 @@ module.exports = async (ctx) => { .map((_, ele) => { const $item = cheerio.load(ele); const leftNode = $item('.overlay-container'); - const relativeLink = leftNode - .find('a') - .first() - .attr('href'); - const typeName = leftNode - .find('.type-name') - .first() - .text(); - const imgUrl = leftNode - .find('img') - .first() - .attr('src'); + const relativeLink = leftNode.find('a').first().attr('href'); + const typeName = leftNode.find('.type-name').first().text(); + const imgUrl = leftNode.find('img').first().attr('src'); const rightNode = $item('.home-info-content'); const infoType = rightNode.find('.user-name').contents()[0].data; const infoTitle = rightNode.find('.user-content').text(); diff --git a/lib/routes/hpoi/user.js b/lib/routes/hpoi/user.js index abc52cc1e2..1168938873 100644 --- a/lib/routes/hpoi/user.js +++ b/lib/routes/hpoi/user.js @@ -21,23 +21,12 @@ module.exports = async (ctx) => { return { title: a.text(), link: 'https://www.hpoi.net/' + a.attr('href'), - description: `
制作:${item - .find('.badge') - .eq(0) - .text()}
发售:${item - .find('.badge') - .eq(1) - .text()}`, + description: `
制作:${item.find('.badge').eq(0).text()}
发售:${item.find('.badge').eq(1).text()}`, }; }) .get(); - const title = - $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + - $('.navbar-nav .active') - .eq(0) - .text() + - '的手办'; + const title = $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + $('.navbar-nav .active').eq(0).text() + '的手办'; ctx.state.data = { title: title, diff --git a/lib/routes/hupu/bbs.js b/lib/routes/hupu/bbs.js index 1dc578a5e6..d5c9d69a0b 100644 --- a/lib/routes/hupu/bbs.js +++ b/lib/routes/hupu/bbs.js @@ -29,18 +29,11 @@ module.exports = async (ctx) => { const list = $('ul.for-list li') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('div.titlelink.box > a.truetit') - .text() - .trim(), - link: $(this) - .find('div.titlelink.box > a.truetit') - .attr('href'), - author: $(this) - .find('a.aulink') - .text(), + title: $(this).find('div.titlelink.box > a.truetit').text().trim(), + link: $(this).find('div.titlelink.box > a.truetit').attr('href'), + author: $(this).find('a.aulink').text(), }; return info; }) diff --git a/lib/routes/huxiu/author.js b/lib/routes/huxiu/author.js index 9e2f0f526e..04861aac94 100644 --- a/lib/routes/huxiu/author.js +++ b/lib/routes/huxiu/author.js @@ -14,9 +14,7 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(response.data); - const author = $('.user-name') - .text() - .trim(); + const author = $('.user-name').text().trim(); const list = $('.message-box > .mod-art > a') .slice(0, 10) diff --git a/lib/routes/huxiu/utils.js b/lib/routes/huxiu/utils.js index 7a1d27b21d..e15b69d878 100644 --- a/lib/routes/huxiu/utils.js +++ b/lib/routes/huxiu/utils.js @@ -26,9 +26,7 @@ const ProcessFeed = async (list, cache) => { .each((i, e) => (e.tagName = 'h3')); return { - title: $('.article__title') - .text() - .trim(), + title: $('.article__title').text().trim(), description: $('.article__top-img-video') + $('.article__content').html(), pubDate: date($('.article__time').text(), 8), author: $('.author-info__username').text(), diff --git a/lib/routes/ikea/uk/new.js b/lib/routes/ikea/uk/new.js index 4698f5499c..57b516d3e5 100644 --- a/lib/routes/ikea/uk/new.js +++ b/lib/routes/ikea/uk/new.js @@ -23,31 +23,17 @@ module.exports = async (ctx) => { if (products.length > 0) { for (const p of products) { - let title = - $(p) - .find('.product-compact__name') - .text() + ' '; + let title = $(p).find('.product-compact__name').text() + ' '; - title += - $(p) - .find('.product-compact__type') - .text() - .trim() + ' '; + title += $(p).find('.product-compact__type').text().trim() + ' '; - title += `[${$(p) - .find('.product-compact__price') - .text() - .trim()}]`; + title += `[${$(p).find('.product-compact__price').text().trim()}]`; - const link = $(p) - .find('.product-compact__spacer > a') - .attr('href'); + const link = $(p).find('.product-compact__spacer > a').attr('href'); items.push({ title, - description: ` img') - .attr('src')}'>`, + description: ` img').attr('src')}'>`, link, }); } diff --git a/lib/routes/ikea/uk/offer.js b/lib/routes/ikea/uk/offer.js index 414f951d59..44f190dd85 100644 --- a/lib/routes/ikea/uk/offer.js +++ b/lib/routes/ikea/uk/offer.js @@ -12,32 +12,17 @@ module.exports = async (ctx) => { if (products.length > 0) { for (const p of products) { - let title = - $(p) - .find('.product-compact__name') - .text() + ' '; + let title = $(p).find('.product-compact__name').text() + ' '; - title += - $(p) - .find('.product-compact__type') - .text() - .trim() + ' '; + title += $(p).find('.product-compact__type').text().trim() + ' '; - title += `[${$(p) - .find('.product-compact__comparable-price-element') - .text()} ▶️ ${$(p) - .find('.product-compact__price.product-compact__price--family') - .text()}]`; + title += `[${$(p).find('.product-compact__comparable-price-element').text()} ▶️ ${$(p).find('.product-compact__price.product-compact__price--family').text()}]`; - const link = $(p) - .find('.product-compact__spacer > a') - .attr('href'); + const link = $(p).find('.product-compact__spacer > a').attr('href'); items.push({ title, - description: ` img') - .attr('src')}'>`, + description: ` img').attr('src')}'>`, link, }); } diff --git a/lib/routes/instapaper/person.js b/lib/routes/instapaper/person.js index 82686f168b..2928ed17dc 100644 --- a/lib/routes/instapaper/person.js +++ b/lib/routes/instapaper/person.js @@ -10,17 +10,11 @@ module.exports = async (ctx) => { const out = $('article.article_item.article_browse') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('div.js_title_row.title_row a') - .attr('title'), - link: $(this) - .find('div.js_title_row.title_row a') - .attr('href'), - description: $(this) - .find('div.article_preview') - .text(), + title: $(this).find('div.js_title_row.title_row a').attr('title'), + link: $(this).find('div.js_title_row.title_row a').attr('href'), + description: $(this).find('div.article_preview').text(), }; return info; }) diff --git a/lib/routes/iplay/home.js b/lib/routes/iplay/home.js index aa97da300e..cf33235ea5 100644 --- a/lib/routes/iplay/home.js +++ b/lib/routes/iplay/home.js @@ -18,9 +18,7 @@ module.exports = async (ctx) => { const result = await util.ProcessFeed(list, ctx.cache); ctx.state.data = { - title: $('title') - .text() - .split('-')[0], + title: $('title').text().split('-')[0], link: url, description: $('meta[name="description"]').attr('content'), item: result, diff --git a/lib/routes/ipsw/index.js b/lib/routes/ipsw/index.js index f268f56a5b..89d5a5c6bc 100644 --- a/lib/routes/ipsw/index.js +++ b/lib/routes/ipsw/index.js @@ -31,11 +31,9 @@ module.exports = async (ctx) => { let list = {}; if (pname.search(',') === -1) { list = $('.products a') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('img') - .attr('alt'), + title: $(this).find('img').attr('alt'), link: $(this).attr('href'), }; return info; @@ -43,20 +41,11 @@ module.exports = async (ctx) => { .get(); } else { list = $('.firmware') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('td') - .eq(1) - .text(), + title: $(this).find('td').eq(1).text(), link: replaceurl($(this).attr('onclick')), - date: cdate( - $(this) - .find('td') - .eq(2) - .text() - .trim() - ), + date: cdate($(this).find('td').eq(2).text().trim()), }; return info; }) @@ -96,25 +85,12 @@ module.exports = async (ctx) => { const description = $('div.selector__wizard').html(); let removeString; if (pname.search(',') === -1) { - removeString = $('tr.firmware') - .first() - .find('td') - .eq(2) - .text() - .trim(); + removeString = $('tr.firmware').first().find('td').eq(2).text().trim(); } else { - removeString = $('div.table-responsive table tr') - .first() - .find('td') - .text() - .trim(); + removeString = $('div.table-responsive table tr').first().find('td').text().trim(); } // 处理发布日期,以表格第一行的日期为最新的发布日期 - removeString = removeString - .replace('th', '') - .replace('nd', '') - .replace('st', '') - .replace('rd', ''); + removeString = removeString.replace('th', '').replace('nd', '').replace('st', '').replace('rd', ''); const rdate = removeString.replace(/ /g, ','); const single = { title: title, diff --git a/lib/routes/iqiyi/dongman.js b/lib/routes/iqiyi/dongman.js index 8f6acdbdfb..ea68ee4eae 100644 --- a/lib/routes/iqiyi/dongman.js +++ b/lib/routes/iqiyi/dongman.js @@ -19,32 +19,21 @@ module.exports = async (ctx) => { const list = $('li[data-albumlist-elem="playItem"]'); ctx.state.data = { - title: $('title') - .text() - .split('-')[0], + title: $('title').text().split('-')[0], link: `http://www.iqiyi.com/${id}.html`, description: description, item: list && list .map((index, item) => { - const episode = $(item) - .find('p.site-piclist_info_title a') - .text() - .trim(); - const describe = $(item) - .find('p.site-piclist_info_describe a') - .text(); + const episode = $(item).find('p.site-piclist_info_title a').text().trim(); + const describe = $(item).find('p.site-piclist_info_describe a').text(); const title = `${episode}-${describe}`; return { title, - description: ``, - link: $(item) - .find('.site-piclist_pic .site-piclist_pic_link') - .attr('href'), + description: ``, + link: $(item).find('.site-piclist_pic .site-piclist_pic_link').attr('href'), }; }) .get() diff --git a/lib/routes/iqiyi/video.js b/lib/routes/iqiyi/video.js index c695d5e5c0..2884b5e72b 100644 --- a/lib/routes/iqiyi/video.js +++ b/lib/routes/iqiyi/video.js @@ -28,25 +28,13 @@ module.exports = async (ctx) => { list && list .map((index, item) => { - const title = $(item) - .find('.site-piclist_pic a') - .attr('data-title'); + const title = $(item).find('.site-piclist_pic a').attr('data-title'); return { title, - description: ``, - pubDate: new Date( - $(item) - .find('.playTimes_status.tl') - .text() - .substring(0, 10) - .replace(/-/g, '/') - ).toUTCString(), - link: $(item) - .find('.site-piclist_pic a') - .attr('href'), + description: ``, + pubDate: new Date($(item).find('.playTimes_status.tl').text().substring(0, 10).replace(/-/g, '/')).toUTCString(), + link: $(item).find('.site-piclist_pic a').attr('href'), }; }) .get(), diff --git a/lib/routes/ithome/ranking.js b/lib/routes/ithome/ranking.js index 35ef2b784f..46e84162c3 100644 --- a/lib/routes/ithome/ranking.js +++ b/lib/routes/ithome/ranking.js @@ -17,22 +17,16 @@ module.exports = async (ctx) => { const title = config[option]; - let elem = $('.lst.lst-2.hot-list') - .find('.bx') - .first(); + let elem = $('.lst.lst-2.hot-list').find('.bx').first(); for (let i = 0; i < Number(option) - 1; ++i) { elem = elem.next(); } const list = elem .find('li') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), }; return info; }) diff --git a/lib/routes/itslide/new.js b/lib/routes/itslide/new.js index 86b28ad141..d7d63b6de7 100644 --- a/lib/routes/itslide/new.js +++ b/lib/routes/itslide/new.js @@ -18,25 +18,11 @@ module.exports = async (ctx) => { title: 'ITSlide - 专注于PPT幻灯片的分享平台', item: posts .map((_, item) => { - const title = $(item) - .find('a') - .attr('title'); - const link = - baseUrl + - '/' + - $(item) - .find('a') - .attr('href') - .slice(1); - const upTime = $(item) - .find('.mod-post-tip .pr') - .text(); - const views = $(item) - .find('.mod-post-tip .pl') - .text(); - const imgSrc = $(item) - .find('img') - .attr('src'); + const title = $(item).find('a').attr('title'); + const link = baseUrl + '/' + $(item).find('a').attr('href').slice(1); + const upTime = $(item).find('.mod-post-tip .pr').text(); + const views = $(item).find('.mod-post-tip .pl').text(); + const imgSrc = $(item).find('img').attr('src'); return { link: link, @@ -46,9 +32,7 @@ module.exports = async (ctx) => { 浏览:${views}
预览:
全文:${link}`, - pubDate: $(item) - .find('.mod-post-tip .pr') - .text(), + pubDate: $(item).find('.mod-post-tip .pr').text(), }; }) .get(), diff --git a/lib/routes/jandan/pic.js b/lib/routes/jandan/pic.js index d4cd9942ba..13f77eb22e 100644 --- a/lib/routes/jandan/pic.js +++ b/lib/routes/jandan/pic.js @@ -24,10 +24,7 @@ module.exports = async (ctx) => { } // Get current comment's link. - const link = `https://jandan.net${$(item) - .find('.righttext') - .find('a') - .attr('href')}`; + const link = `https://jandan.net${$(item).find('.righttext').find('a').attr('href')}`; const imgList = []; $(item) @@ -43,10 +40,7 @@ module.exports = async (ctx) => { return; } - const text = - $(item) - .find('.text p') - .text() || ''; + const text = $(item).find('.text p').text() || ''; // TODO: should load user's comments. diff --git a/lib/routes/japanpost/index.js b/lib/routes/japanpost/index.js index f7d81c4c7e..0bb190944c 100644 --- a/lib/routes/japanpost/index.js +++ b/lib/routes/japanpost/index.js @@ -32,20 +32,11 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(response.data); - const list = $('.tableType01') - .eq(1) - .find('tr') - .slice(2); + const list = $('.tableType01').eq(1).find('tr').slice(2); const listEven = list.even(); - const packageType = $('.tableType01') - .eq(0) - .find('tr') - .eq(1) - .find('td') - .eq(1) - .text(); + const packageType = $('.tableType01').eq(0).find('tr').eq(1).find('td').eq(1).text(); ctx.state.data = { title: `${baseTitle} ${packageType} ${reqCode}`, @@ -56,18 +47,9 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); const itemTd = item.find('td'); - const packageStatus = itemTd - .eq(1) - .text() - .trim(); - const packageRegion = itemTd - .eq(4) - .text() - .trim(); - const packageOffice = itemTd - .eq(3) - .text() - .trim(); + const packageStatus = itemTd.eq(1).text().trim(); + const packageRegion = itemTd.eq(4).text().trim(); + const packageOffice = itemTd.eq(3).text().trim(); const itemTitle = `${packageStatus} ${packageRegion} ${packageOffice}`; const itemDescription = itemTd.eq(2).text(); const itemPubDateText = itemTd.eq(0).text(); diff --git a/lib/routes/japanpost/utils.js b/lib/routes/japanpost/utils.js index 88d33353f9..07c3cee22e 100644 --- a/lib/routes/japanpost/utils.js +++ b/lib/routes/japanpost/utils.js @@ -2,10 +2,10 @@ const cheerio = require('cheerio'); const crypto = require('crypto'); function utils() { - this.expandOdd = function() { - cheerio.prototype.odd = function() { + this.expandOdd = function () { + cheerio.prototype.odd = function () { const odds = []; - this.each(function(index, item) { + this.each(function (index, item) { if (index % 2 === 1) { odds.push(item); } @@ -14,10 +14,10 @@ function utils() { }; }; - this.expandEven = function() { - cheerio.prototype.even = function() { + this.expandEven = function () { + cheerio.prototype.even = function () { const evens = []; - this.each(function(index, item) { + this.each(function (index, item) { if (index % 2 === 0) { evens.push(item); } @@ -26,10 +26,10 @@ function utils() { }; }; - this.expandReverse = function() { - cheerio.prototype.reverse = function() { + this.expandReverse = function () { + cheerio.prototype.reverse = function () { const reverses = []; - this.each(function(index, item) { + this.each(function (index, item) { reverses.push(item); }); reverses.reverse(); @@ -37,7 +37,7 @@ function utils() { }; }; - this.generateGuid = function(t) { + this.generateGuid = function (t) { const hash = crypto.createHash('sha512'); hash.update(t); const r = hash.digest('hex').toUpperCase(); diff --git a/lib/routes/javbus/util.js b/lib/routes/javbus/util.js index 6eebf299fd..5e4a6086ba 100644 --- a/lib/routes/javbus/util.js +++ b/lib/routes/javbus/util.js @@ -5,9 +5,7 @@ exports.getPage = async (url, ctx) => { const { data } = await got(url); const $ = load(data); - const pageTitle = `JavBus - ${$('head > title') - .text() - .replace(' - JavBus', '')}`; + const pageTitle = `JavBus - ${$('head > title').text().replace(' - JavBus', '')}`; return { title: pageTitle, @@ -24,21 +22,11 @@ exports.createHandler = (url) => async (ctx) => { const parseItems = ($, ctx) => $('.movie-box') .map((_, ele) => ({ - title: $(ele) - .find('img') - .attr('title'), - thumb: $(ele) - .find('img') - .attr('src'), + title: $(ele).find('img').attr('title'), + thumb: $(ele).find('img').attr('src'), link: $(ele).attr('href'), - pubDate: new Date( - $(ele) - .find('date:nth-child(4)') - .text() - ).toUTCString(), - aid: $(ele) - .find('date:nth-child(3)') - .text(), + pubDate: new Date($(ele).find('date:nth-child(4)').text()).toUTCString(), + aid: $(ele).find('date:nth-child(3)').text(), })) .toArray() .map(async ({ title, thumb, link, pubDate, aid }) => { @@ -174,7 +162,7 @@ const getDetail = async (link, ctx) => { match = magnettable.match(//gm); let magnetlinks = []; if (match) { - magnetlinks = match.map(function(str) { + magnetlinks = match.map(function (str) { // magnet地址 const mlink = /td width="70%" onclick="window.open\('(magnet.*?)',/.exec(str)[1]; // console.log(str); diff --git a/lib/routes/jdlingyu/index.js b/lib/routes/jdlingyu/index.js index 1bf70e3562..c108e335db 100644 --- a/lib/routes/jdlingyu/index.js +++ b/lib/routes/jdlingyu/index.js @@ -30,15 +30,9 @@ module.exports = async (ctx) => { return Promise.resolve({ title: a.text(), description: description, - author: $(div) - .find('.post-header .users') - .text(), + author: $(div).find('.post-header .users').text(), link: link, - pubDate: new Date( - $(div) - .find('.post-header time') - .attr('datetime') - ).toUTCString(), + pubDate: new Date($(div).find('.post-header time').attr('datetime')).toUTCString(), }); }) ); diff --git a/lib/routes/jiemian/list.js b/lib/routes/jiemian/list.js index ed72259b47..a2d754ad8c 100644 --- a/lib/routes/jiemian/list.js +++ b/lib/routes/jiemian/list.js @@ -16,15 +16,11 @@ module.exports = async (ctx) => { switch (className) { case 'list-view': type = 'list'; - list = $('.item-news') - .slice(0, 10) - .get(); + list = $('.item-news').slice(0, 10).get(); break; case 'list-view card': type = 'card'; - list = $('.news-view') - .slice(0, 10) - .get(); + list = $('.news-view').slice(0, 10).get(); break; default: diff --git a/lib/routes/jingdong/zhongchou.js b/lib/routes/jingdong/zhongchou.js index bd211bb434..25d7904a26 100644 --- a/lib/routes/jingdong/zhongchou.js +++ b/lib/routes/jingdong/zhongchou.js @@ -56,33 +56,15 @@ module.exports = async (ctx) => { const out = $('body > div.wrap.mt20 > div.l-info > div.l-result > ul > li') .slice(0, 10) - .map(function() { - const image = - 'https:' + - $(this) - .find('a.link-pic > img') - .attr('src'); - const information = $(this) - .find('div.p-outter > div.p-items > ul') - .html() - .trim(); + .map(function () { + const image = 'https:' + $(this).find('a.link-pic > img').attr('src'); + const information = $(this).find('div.p-outter > div.p-items > ul').html().trim(); const description = `
${information}`; const info = { - link: url.resolve( - host, - $(this) - .find('a.link-pic') - .attr('href') - ), + link: url.resolve(host, $(this).find('a.link-pic').attr('href')), description: description, - title: - $(this) - .find('div.i-tits.no-color-choose > a > h4') - .text() || - $(this) - .find('div.i-tits > a > h4') - .text(), + title: $(this).find('div.i-tits.no-color-choose > a > h4').text() || $(this).find('div.i-tits > a > h4').text(), }; return info; }) diff --git a/lib/routes/jinritoutiao/keyword.js b/lib/routes/jinritoutiao/keyword.js index 0ece0d98d8..c7c86cd350 100644 --- a/lib/routes/jinritoutiao/keyword.js +++ b/lib/routes/jinritoutiao/keyword.js @@ -11,7 +11,7 @@ module.exports = async (ctx) => { }, }); let data = response.data.data; - data = data.filter(function(item) { + data = data.filter(function (item) { return !item.cell_type; }); diff --git a/lib/routes/juejin/trending.js b/lib/routes/juejin/trending.js index 6b98d9cf63..f70e77353d 100644 --- a/lib/routes/juejin/trending.js +++ b/lib/routes/juejin/trending.js @@ -12,7 +12,7 @@ module.exports = async (ctx) => { let id = 'all'; let name = ''; - await got_ins.get('https://gold-tag-ms.juejin.im/v1/categories').then(function(response) { + await got_ins.get('https://gold-tag-ms.juejin.im/v1/categories').then(function (response) { const [item] = response.data.d.categoryList.filter((item) => category.localeCompare(item.title) === 0); if (item !== undefined) { id = item.id; diff --git a/lib/routes/juesheng/index.js b/lib/routes/juesheng/index.js index dcba4a61ce..7c3adca2ae 100644 --- a/lib/routes/juesheng/index.js +++ b/lib/routes/juesheng/index.js @@ -7,14 +7,8 @@ module.exports = async (ctx) => { const postList = $('.sec-box #informationBox li').get(); const result = await Promise.all( postList.map(async (item) => { - const title = $(item) - .find('.news-item-title') - .find('a') - .text(); - const link = $(item) - .find('.news-item-title') - .find('a') - .attr('href'); + const title = $(item).find('.news-item-title').find('a').text(); + const link = $(item).find('.news-item-title').find('a').attr('href'); const guid = link; const single = { @@ -36,14 +30,8 @@ module.exports = async (ctx) => { single.pubDate = pubDate_value; } else { const temp = await got(link); - single.description = $(temp.data) - .find('.content-box') - .html(); - single.pubDate = new Date( - $(temp.data) - .find('.part-time') - .text() - ).toUTCString(); + single.description = $(temp.data).find('.content-box').html(); + single.pubDate = new Date($(temp.data).find('.part-time').text()).toUTCString(); ctx.cache.set(description_key, single.description); ctx.cache.set(pubDate_key, single.pubDate); diff --git a/lib/routes/keyakizaka46/blog.js b/lib/routes/keyakizaka46/blog.js index 13763cd855..a96ba6fdde 100644 --- a/lib/routes/keyakizaka46/blog.js +++ b/lib/routes/keyakizaka46/blog.js @@ -26,20 +26,10 @@ module.exports = async (ctx) => { item = $(item); itemPicUrl = `${item.find('img.js-replaceImage').attr('src')}`; return { - title: item - .find('p.ttl') - .text() - .trim(), - link: item - .find('a') - .first() - .attr('href'), + title: item.find('p.ttl').text().trim(), + link: item.find('a').first().attr('href'), pubDate: item.find('div.box-blog time').text(), - author: item - .find('p.ttl') - .next() - .text() - .trim(), + author: item.find('p.ttl').next().text().trim(), description: ``, }; }) diff --git a/lib/routes/keyakizaka46/news.js b/lib/routes/keyakizaka46/news.js index 8e2aad92a7..c4bca71137 100644 --- a/lib/routes/keyakizaka46/news.js +++ b/lib/routes/keyakizaka46/news.js @@ -24,15 +24,9 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: item - .find('div.text a') - .first() - .text(), + title: item.find('div.text a').first().text(), link: item.find('div.text a').attr('href'), - pubDate: item - .find('div.date') - .first() - .text(), + pubDate: item.find('div.date').first().text(), }; }) .get(), diff --git a/lib/routes/kuaidi100/utils.js b/lib/routes/kuaidi100/utils.js index 15477446bd..afd680ccda 100644 --- a/lib/routes/kuaidi100/utils.js +++ b/lib/routes/kuaidi100/utils.js @@ -80,10 +80,7 @@ async function getCompanyList(ctx) { // Parsing the js file try { - list = list - .substr(12) - .replace(/};/g, '}') - .replace(/'/g, '"'); + list = list.substr(12).replace(/};/g, '}').replace(/'/g, '"'); list = JSON.parse(list); list = list.company; } catch (e) { diff --git a/lib/routes/latexstudio/home.js b/lib/routes/latexstudio/home.js index 067bc209e1..c14b2f8fb3 100644 --- a/lib/routes/latexstudio/home.js +++ b/lib/routes/latexstudio/home.js @@ -16,9 +16,7 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(detail.data); $('.tac').remove(); - const author = $('.article-meta .item:last-child') - .text() - .replace('稿源:', ''); + const author = $('.article-meta .item:last-child').text().replace('稿源:', ''); const description = $('.article-content').html(); return { description, author }; }; @@ -28,11 +26,7 @@ module.exports = async (ctx) => { .slice(0, 10) .map(async (index, item) => { const $item = $(item); - const originalUrl = $item - .find('h2') - .find('a') - .attr('href') - .replace('http', 'https'); + const originalUrl = $item.find('h2').find('a').attr('href').replace('http', 'https'); const cache = await ctx.cache.get(originalUrl); if (cache) { @@ -42,10 +36,7 @@ module.exports = async (ctx) => { const { description, author } = await ProcessFeed(originalUrl); const single = { - title: `${$item - .find('a.cat') - .text() - .trim()} - ${$item.find('h2', 'a').text()}`, + title: `${$item.find('a.cat').text().trim()} - ${$item.find('h2', 'a').text()}`, link: originalUrl, description, author, diff --git a/lib/routes/learnku/topic.js b/lib/routes/learnku/topic.js index d3309c05f0..a92a5332a2 100644 --- a/lib/routes/learnku/topic.js +++ b/lib/routes/learnku/topic.js @@ -36,17 +36,13 @@ module.exports = async (ctx) => { item: list .map((item) => { const $ = cheerio.load(item); - const categoryName = $('.category-name') - .text() - .trim(); + const categoryName = $('.category-name').text().trim(); if (['置顶', '广告'].includes(categoryName)) { return ''; } $('.topic-title i').remove(); return { - title: $('.topic-title') - .text() - .trim(), + title: $('.topic-title').text().trim(), category: categoryName, link: $('.topic-title-wrap').attr('href'), pubDate: new Date($('.timeago').attr('title')).toUTCString(), diff --git a/lib/routes/leetcode/articles.js b/lib/routes/leetcode/articles.js index c169b4d891..b143c044de 100644 --- a/lib/routes/leetcode/articles.js +++ b/lib/routes/leetcode/articles.js @@ -12,20 +12,12 @@ module.exports = async (ctx) => { const list = $('a.list-group-item') .slice(0, 10) .filter((i, e) => $(e).find('h4.media-heading i').length === 0) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h4.media-heading') - .text() - .trim(), - author: $(this) - .find('.text-500') - .text(), + title: $(this).find('h4.media-heading').text().trim(), + author: $(this).find('.text-500').text(), link: $(this).attr('href'), - date: $(this) - .find('p.pull-right.media-date strong') - .text() - .trim(), + date: $(this).find('p.pull-right.media-date strong').text().trim(), }; return info; }) @@ -43,13 +35,7 @@ module.exports = async (ctx) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const description = - $('#question-preview') - .html() - .trim() + - $('.article-body') - .html() - .trim(); + const description = $('#question-preview').html().trim() + $('.article-body').html().trim(); const single = { title: info.title, diff --git a/lib/routes/leetcode/check-us.js b/lib/routes/leetcode/check-us.js index 3febded797..a07ada1bde 100644 --- a/lib/routes/leetcode/check-us.js +++ b/lib/routes/leetcode/check-us.js @@ -13,37 +13,15 @@ module.exports = async (ctx) => { }); const data = response.data; const $ = cheerio.load(data); - const username = $('div.panel-body') - .find('p') - .text(); // 用户名 - const img = $('div.panel-body') - .find('img') - .attr('src'); // 用户的头像 + const username = $('div.panel-body').find('p').text(); // 用户名 + const img = $('div.panel-body').find('img').attr('src'); // 用户的头像 const src = ``; - const solvedQuestion = $('ul.list-group') - .eq(2) - .children() - .eq(0) - .find('span') - .text(); // 解决的题目 - const acceptedSubmission = $('ul.list-group') - .eq(2) - .children() - .eq(1) - .find('span') - .text(); // 通过的提交 - const acceptanceRate = $('ul.list-group') - .eq(2) - .children() - .eq(2) - .find('span') - .text(); // 通过率 + const solvedQuestion = $('ul.list-group').eq(2).children().eq(0).find('span').text(); // 解决的题目 + const acceptedSubmission = $('ul.list-group').eq(2).children().eq(1).find('span').text(); // 通过的提交 + const acceptanceRate = $('ul.list-group').eq(2).children().eq(2).find('span').text(); // 通过率 const state = ' Most recent submissions'; const description = 'Solved Question: ' + solvedQuestion + '
Accepted Submission: ' + acceptedSubmission + '
Acceptance Rate: ' + acceptanceRate + '
' + src; - const list = $('ul.list-group') - .eq(-1) - .children() - .get(); + const list = $('ul.list-group').eq(-1).children().get(); const result = await util.ProcessFeed(list); ctx.state.data = { title: username + state, diff --git a/lib/routes/leetcode/utils.js b/lib/routes/leetcode/utils.js index 9a0f54a22b..86e039499e 100644 --- a/lib/routes/leetcode/utils.js +++ b/lib/routes/leetcode/utils.js @@ -6,17 +6,9 @@ const ProcessFeed = async (list) => { list.map(async (item) => { const $ = cheerio.load(item); const $title = $('b'); - const description = - $('span') - .eq(0) - .text() + - $('span') - .eq(1) - .text(); + const description = $('span').eq(0).text() + $('span').eq(1).text(); // 还原相对链接为绝对链接 - const pubDate = $('span') - .eq(2) - .text(); + const pubDate = $('span').eq(2).text(); const bb = $('a[href]').get()[0]; const itemUrl = host + $(bb).attr('href'); let n = 0, diff --git a/lib/routes/letterboxd/utils.js b/lib/routes/letterboxd/utils.js index bd7309059a..6a524dec42 100644 --- a/lib/routes/letterboxd/utils.js +++ b/lib/routes/letterboxd/utils.js @@ -109,7 +109,7 @@ const getFollowingData = async (ctx, username, url, title) => { const $ = cheerio.load(response.data); const list = $('.person-table td.table-person').get(); - const users = list.map(function(user) { + const users = list.map(function (user) { const $ = cheerio.load(user); return $('a.name').attr('href'); }); diff --git a/lib/routes/lfsyd/index.js b/lib/routes/lfsyd/index.js index 557b8680e4..674dcdf931 100644 --- a/lib/routes/lfsyd/index.js +++ b/lib/routes/lfsyd/index.js @@ -40,7 +40,7 @@ module.exports = async (ctx) => { link: `${host}/web/${link}/${element.feed.sourceID.split('/')[0]}?${video}title=${encodeURI(element.feed.seedTitle)}&remark=seed`, }; }) - .filter(function(item) { + .filter(function (item) { return item.title !== undefined; }); diff --git a/lib/routes/linkedkeeper/index.js b/lib/routes/linkedkeeper/index.js index 3fcd8651b5..951f6def68 100644 --- a/lib/routes/linkedkeeper/index.js +++ b/lib/routes/linkedkeeper/index.js @@ -18,37 +18,16 @@ module.exports = async (ctx) => { const list = $('tbody').find('td'); ctx.state.data = { - title: `${$('.blog_en_title') - .text() - .trim() || - $('.active') - .text() - .trim()} - LinkedKeeper`, + title: `${$('.blog_en_title').text().trim() || $('.active').text().trim()} - LinkedKeeper`, link: res.request.res.responseUrl, item: list .map((index, item) => { item = $(item); - const pubDate = new Date( - item - .find('dd:nth-child(3)') - .text() - .trim() - .replace('月', '-') - .replace('日', '') - ); + const pubDate = new Date(item.find('dd:nth-child(3)').text().trim().replace('月', '-').replace('日', '')); pubDate.setFullYear(new Date().getFullYear()); return { - title: item - .find('a.blog_weight') - .text() - .trim(), - description: `${item - .find('a.blog_weight') - .text() - .trim()} - ${item - .find('.blog_author_13') - .text() - .trim()}`, + title: item.find('a.blog_weight').text().trim(), + description: `${item.find('a.blog_weight').text().trim()} - ${item.find('.blog_author_13').text().trim()}`, pubDate: pubDate.toUTCString(), link: `http://www.linkedkeeper.com${item.find('a').attr('href')}`, }; diff --git a/lib/routes/lofter/tag.js b/lib/routes/lofter/tag.js index 04866a1d59..2aa8c1e768 100644 --- a/lib/routes/lofter/tag.js +++ b/lib/routes/lofter/tag.js @@ -18,9 +18,7 @@ module.exports = async (ctx) => { const response = await got.get(url); const $ = cheerio.load(response.data); - const list = $('.m-mlist > .mlistcnt') - .slice(1) - .toArray(); + const list = $('.m-mlist > .mlistcnt').slice(1).toArray(); ctx.state.data = { title: `lofter话题 - ${name} - ${titles[type]}`, @@ -28,11 +26,7 @@ module.exports = async (ctx) => { item: list.map((item) => { item = $(item); - const author = item - .find('.w-who > .ptag') - .first() - .text() - .trim(); + const author = item.find('.w-who > .ptag').first().text().trim(); const images = item.find('img[data-origin]'); for (let k = 0; k < images.length; k++) { @@ -43,7 +37,7 @@ module.exports = async (ctx) => { item.find('.js-digest').remove(); - item.find('a:not([href])').each(function() { + item.find('a:not([href])').each(function () { $(this).replaceWith($(this).html()); }); diff --git a/lib/routes/loveheaven/update.js b/lib/routes/loveheaven/update.js index ec0c6bacfb..96177b0bc3 100644 --- a/lib/routes/loveheaven/update.js +++ b/lib/routes/loveheaven/update.js @@ -15,7 +15,7 @@ module.exports = async (ctx) => { const manga_name = $('.manga-info > h1').text(); const manga_other_names = $('.manga-info > li:nth-child(3)').text(); const manga_author = $('a.btn-info') - .map(function() { + .map(function () { return $(this).text(); }) .get() diff --git a/lib/routes/ltaaa/_article.js b/lib/routes/ltaaa/_article.js index 069f0db7ad..6f117a9d11 100644 --- a/lib/routes/ltaaa/_article.js +++ b/lib/routes/ltaaa/_article.js @@ -18,12 +18,7 @@ module.exports = async function get_article(url) { const title = $('div.post-title > h1').text(); const author = $('div.post-param > a').text(); - const pub_date_raw = $('div.post-param') - .clone() - .children() - .remove() - .end() - .text(); + const pub_date_raw = $('div.post-param').clone().children().remove().end().text(); let date = new Date(pub_date_raw); date.setHours(date.getHours() - 8); date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds())); diff --git a/lib/routes/luogu/contest.js b/lib/routes/luogu/contest.js index 024e0636d4..0bdff5483a 100644 --- a/lib/routes/luogu/contest.js +++ b/lib/routes/luogu/contest.js @@ -10,24 +10,11 @@ module.exports = async (ctx) => { const out = $('.am-panel-hd ') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: - $(this) - .find('a') - .text() || $(this).text(), - description: - $(this).html() + - $(this) - .parent() - .find('.am-panel-bd') - .html(), - link: resolve_url( - 'https://www.luogu.com.cn', - $(this) - .find('a') - .attr('href') - ), + title: $(this).find('a').text() || $(this).text(), + description: $(this).html() + $(this).parent().find('.am-panel-bd').html(), + link: resolve_url('https://www.luogu.com.cn', $(this).find('a').attr('href')), }; return info; }) diff --git a/lib/routes/luogu/daily.js b/lib/routes/luogu/daily.js index 6339b59208..eb1e2133da 100644 --- a/lib/routes/luogu/daily.js +++ b/lib/routes/luogu/daily.js @@ -10,16 +10,11 @@ module.exports = async (ctx) => { const out = $('div.am-comment-main > div > p') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: - $(this) - .find('strong') - .text() || $(this).text(), + title: $(this).find('strong').text() || $(this).text(), description: $(this).html(), - link: $(this) - .find('a') - .attr('href'), + link: $(this).find('a').attr('href'), }; return info; }) diff --git a/lib/routes/maitta/index.js b/lib/routes/maitta/index.js index ef8f62085a..c1f850891f 100644 --- a/lib/routes/maitta/index.js +++ b/lib/routes/maitta/index.js @@ -17,32 +17,11 @@ module.exports = async (ctx) => { item = $(item); return { title: item.find('h3').text(), - description: item - .find('.linecontent') - .text() - .trim(), - link: `https:${ - item - .find('a') - .first() - .attr('href') - .split('?')[0] - }`, - pubDate: new Date( - item - .find('.onairdate') - .text() - .split('日')[0] - .replace(/年|月/g, '-') - ).toUTCString(), + description: item.find('.linecontent').text().trim(), + link: `https:${item.find('a').first().attr('href').split('?')[0]}`, + pubDate: new Date(item.find('.onairdate').text().split('日')[0].replace(/年|月/g, '-')).toUTCString(), itunes_item_image: 'https://cdn.ibc.co.jp/radio/maitta/audio/images/og.png', - enclosure_url: `https:${ - item - .find('a') - .first() - .attr('href') - .split('?')[0] - }`, // 音频链接 + enclosure_url: `https:${item.find('a').first().attr('href').split('?')[0]}`, // 音频链接 enclosure_type: 'audio/mpeg', }; }), diff --git a/lib/routes/manhuadb/comics.js b/lib/routes/manhuadb/comics.js index 3a9a39d045..6d6e386bd6 100644 --- a/lib/routes/manhuadb/comics.js +++ b/lib/routes/manhuadb/comics.js @@ -19,12 +19,8 @@ module.exports = async (ctx) => { description: '漫画DB', item: list .map((i, item) => ({ - title: $(item) - .text() - .trim(), - description: $(item) - .text() - .trim(), + title: $(item).text().trim(), + description: $(item).text().trim(), link: host + $(item).attr('href'), })) .get(), diff --git a/lib/routes/manhuagui/comic.js b/lib/routes/manhuagui/comic.js index 58581ff84b..2ccefe6755 100644 --- a/lib/routes/manhuagui/comic.js +++ b/lib/routes/manhuagui/comic.js @@ -6,15 +6,7 @@ const getChapters = ($) => $('.chapter-list > ul') .toArray() .reverse() - .reduce( - (acc, curr) => - acc.concat( - $(curr) - .children('li') - .toArray() - ), - [] - ) + .reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), []) .map((ele) => { const a = $(ele).children('a'); return { diff --git a/lib/routes/meipai/user.js b/lib/routes/meipai/user.js index dbf2965f00..e8c3da812a 100644 --- a/lib/routes/meipai/user.js +++ b/lib/routes/meipai/user.js @@ -17,9 +17,7 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML - const list = $('#mediasList') - .find('li') - .get(); + const list = $('#mediasList').find('li').get(); const name = $('.feed-left .content-l-h2').text(); const result = await util.ProcessFeed(list, ctx.cache); diff --git a/lib/routes/metacritic/release.js b/lib/routes/metacritic/release.js index 54f46f18ad..a8231c429a 100644 --- a/lib/routes/metacritic/release.js +++ b/lib/routes/metacritic/release.js @@ -28,26 +28,16 @@ module.exports = async (ctx) => { const data = response.body; const $ = cheerio.load(data); - const list = $('.list_products > li') - .get() - .slice(0, 10); + const list = $('.list_products > li').get().slice(0, 10); const result = list.map((item) => { const $ = cheerio.load(item); return { - title: $('.product_title') - .text() - .trim(), + title: $('.product_title').text().trim(), url: 'https://www.metacritic.com' + $('.product_title > a').attr('href'), - metascore: $('.brief_metascore') - .text() - .trim(), - userscore: $('.textscore') - .text() - .trim(), - date: $('.release_date > .data') - .text() - .trim(), + metascore: $('.brief_metascore').text().trim(), + userscore: $('.textscore').text().trim(), + date: $('.release_date > .data').text().trim(), }; }); diff --git a/lib/routes/mhw/news.js b/lib/routes/mhw/news.js index fac8cc8f6b..0a545dd23a 100644 --- a/lib/routes/mhw/news.js +++ b/lib/routes/mhw/news.js @@ -21,10 +21,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); return { - title: - $('.h2') - .text() - .trim() || item.title, + title: $('.h2').text().trim() || item.title, description: $('#contents').html(), link: item.link, author: 'MONSTER HUNTER WORLD: ICEBORNE', diff --git a/lib/routes/mhw/update.js b/lib/routes/mhw/update.js index cec281e036..bb8359dd38 100644 --- a/lib/routes/mhw/update.js +++ b/lib/routes/mhw/update.js @@ -31,10 +31,7 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: item - .find('h3') - .text() - .trim(), + title: item.find('h3').text().trim(), link: url2 + item.attr('href'), }; }) @@ -46,9 +43,7 @@ module.exports = async (ctx) => { await ctx.cache.tryGet(item.link, async () => { const response = await got.get(item.link); const $ = cheerio.load(response.data); - const title = $('.page-ttl') - .text() - .trim(); + const title = $('.page-ttl').text().trim(); $('.page-ttl').remove(); return { diff --git a/lib/routes/moxingnet/index.js b/lib/routes/moxingnet/index.js index d55c9aae64..7a40de28ad 100644 --- a/lib/routes/moxingnet/index.js +++ b/lib/routes/moxingnet/index.js @@ -13,11 +13,11 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const list = $('ul.text_list.text_list_f14 li') .get() - .map(function(item) { + .map(function (item) { const $ = cheerio.load(item); return baseUrl + $('a').attr('href'); }) - .filter(function(link) { + .filter(function (link) { return !link.includes('taobao'); }); @@ -31,10 +31,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); let desc = $('#endtext').html(); - const next_page_link = $('#pages') - .children() - .last() - .attr('href'); + const next_page_link = $('#pages').children().last().attr('href'); if (next_page_link !== undefined && baseUrl + next_page_link !== link) { const next_page = await ProcessLink(baseUrl + next_page_link); desc += next_page.desc; diff --git a/lib/routes/mpaypass/main.js b/lib/routes/mpaypass/main.js index 5a8e6ec45c..ad776182bb 100644 --- a/lib/routes/mpaypass/main.js +++ b/lib/routes/mpaypass/main.js @@ -26,20 +26,12 @@ module.exports = async (ctx) => { title_cn = '最新文章'; } const list = $('.newslist') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('#title') - .text(), - link: $(this) - .find('#pic a') - .attr('href'), - pic: $(this) - .find('#pic img') - .attr('src'), - time: $(this) - .find('#time') - .text(), + title: $(this).find('#title').text(), + link: $(this).find('#pic a').attr('href'), + pic: $(this).find('#pic img').attr('src'), + time: $(this).find('#time').text(), }; return info; }) diff --git a/lib/routes/mpaypass/news.js b/lib/routes/mpaypass/news.js index 142d38505e..b4a95419f0 100644 --- a/lib/routes/mpaypass/news.js +++ b/lib/routes/mpaypass/news.js @@ -15,10 +15,7 @@ module.exports = async (ctx) => { const $a = $el.find('.newsbodylist-title a'); const href = $a.attr('href'); const title = $a.text(); - const date = $el - .find('.newsbodylist-title span') - .text() - .split('|')[1]; + const date = $el.find('.newsbodylist-title span').text().split('|')[1]; const key = `${href}`; let description; diff --git a/lib/routes/mzitu/tags.js b/lib/routes/mzitu/tags.js index 4f7afce787..6ea64d8d10 100644 --- a/lib/routes/mzitu/tags.js +++ b/lib/routes/mzitu/tags.js @@ -16,12 +16,8 @@ module.exports = async (ctx) => { link: link, description: '妹子图美女专题栏目,为您精心准备各种美女图片专题,包括名站美女写真,妹子特点分类,美女大全等专题。', item: list.map((item) => ({ - title: $(item) - .find('img') - .attr('alt'), - link: $(item) - .find('a') - .attr('href'), + title: $(item).find('img').attr('alt'), + link: $(item).find('a').attr('href'), })), }; }; diff --git a/lib/routes/mzitu/util.js b/lib/routes/mzitu/util.js index f8f683daa7..d3a90348b5 100644 --- a/lib/routes/mzitu/util.js +++ b/lib/routes/mzitu/util.js @@ -3,18 +3,12 @@ const cheerio = require('cheerio'); exports.getItem = async (ctx, data) => { const $ = cheerio.load(data); - const list = $('#pins li') - .get() - .slice(0, 5); + const list = $('#pins li').get().slice(0, 5); return await Promise.all( list.map(async (item) => { - const title = $(item) - .find('span > a') - .text(); - const item_link = $(item) - .find('span > a') - .attr('href'); + const title = $(item).find('span > a').text(); + const item_link = $(item).find('span > a').attr('href'); const cache = await ctx.cache.get(item_link); let description; diff --git a/lib/routes/namoc/announcement.js b/lib/routes/namoc/announcement.js index d23a625010..4e9849df3b 100644 --- a/lib/routes/namoc/announcement.js +++ b/lib/routes/namoc/announcement.js @@ -10,9 +10,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('.news-list li:not(.clearfix)') - .slice(0, 5) - .get(); + const list = $('.news-list li:not(.clearfix)').slice(0, 5).get(); const proList = []; @@ -55,12 +53,7 @@ module.exports = async (ctx) => { .html() .replace(/src="./g, `src="${absLink}`); out[i].author = '中国美术馆'; - out[i].pubDate = new Date( - full - .find('.news-info span:last-of-type') - .text() - .replace('时间:', '') - ).toUTCString(); + out[i].pubDate = new Date(full.find('.news-info span:last-of-type').text().replace('时间:', '')).toUTCString(); ctx.cache.set(out[i].link, JSON.stringify(out[i])); } ctx.state.data = { diff --git a/lib/routes/namoc/exhibition.js b/lib/routes/namoc/exhibition.js index 12640d7e0a..5f1e3e6685 100644 --- a/lib/routes/namoc/exhibition.js +++ b/lib/routes/namoc/exhibition.js @@ -10,9 +10,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('#content div.rec-exh-news-list div.wrap:nth-of-type(2)') - .find('li') - .get(); + const list = $('#content div.rec-exh-news-list div.wrap:nth-of-type(2)').find('li').get(); const proList = []; const out = await Promise.all( @@ -48,37 +46,17 @@ module.exports = async (ctx) => { let info = full.find('ul.info'); info = $(info).remove('.fav_btn'); - const from = $(info) - .find('script:first-of-type') - .html() - .replace('getExhDate("', '') - .replace('");', ''); - const to = $(info) - .find('script:last-of-type') - .html() - .replace('getExhDate("', '') - .replace('");', ''); + const from = $(info).find('script:first-of-type').html().replace('getExhDate("', '').replace('");', ''); + const to = $(info).find('script:last-of-type').html().replace('getExhDate("', '').replace('");', ''); - $(info) - .find('script:first-of-type') - .replaceWith(from); - $(info) - .find('script:last-of-type') - .replaceWith(to); + $(info).find('script:first-of-type').replaceWith(from); + $(info).find('script:last-of-type').replaceWith(to); const intro = full.find('div.Custom_UnionStyle').html(); const cover = full.find('p.image-list').html(); out[i].description = cover + info + intro; - out[i].author = full - .find('.news-info span:first-of-type') - .text() - .replace('来源:', ''); - out[i].pubDate = new Date( - full - .find('.news-info span:last-of-type') - .text() - .replace('时间:', '') - ).toUTCString(); + out[i].author = full.find('.news-info span:first-of-type').text().replace('来源:', ''); + out[i].pubDate = new Date(full.find('.news-info span:last-of-type').text().replace('时间:', '')).toUTCString(); ctx.cache.set(out[i].link, JSON.stringify(out[i])); } ctx.state.data = { diff --git a/lib/routes/namoc/media.js b/lib/routes/namoc/media.js index 195ae300bf..ecfe951e8a 100644 --- a/lib/routes/namoc/media.js +++ b/lib/routes/namoc/media.js @@ -10,9 +10,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('.news-list li:not(.clearfix)') - .slice(0, 10) - .get(); + const list = $('.news-list li:not(.clearfix)').slice(0, 10).get(); const proList = []; @@ -56,16 +54,8 @@ module.exports = async (ctx) => { .find('div.TRS_Editor') .html() .replace(/src="./g, `src="${absLink}`); - out[i].author = full - .find('.news-info span:first-of-type') - .text() - .replace('来源:', ''); - out[i].pubDate = new Date( - full - .find('.news-info span:last-of-type') - .text() - .replace('时间:', '') - ).toUTCString(); + out[i].author = full.find('.news-info span:first-of-type').text().replace('来源:', ''); + out[i].pubDate = new Date(full.find('.news-info span:last-of-type').text().replace('时间:', '')).toUTCString(); ctx.cache.set(out[i].link, JSON.stringify(out[i])); } } diff --git a/lib/routes/namoc/news.js b/lib/routes/namoc/news.js index 2be05e8af1..582549fff8 100644 --- a/lib/routes/namoc/news.js +++ b/lib/routes/namoc/news.js @@ -10,9 +10,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('.news-list li:not(.clearfix)') - .slice(0, 10) - .get(); + const list = $('.news-list li:not(.clearfix)').slice(0, 10).get(); const proList = []; @@ -56,16 +54,8 @@ module.exports = async (ctx) => { .find('div.TRS_Editor') .html() .replace(/src="./g, `src="${absLink}`); - out[i].author = full - .find('.news-info span:first-of-type') - .text() - .replace('来源:', ''); - out[i].pubDate = new Date( - full - .find('.news-info span:last-of-type') - .text() - .replace('时间:', '') - ).toUTCString(); + out[i].author = full.find('.news-info span:first-of-type').text().replace('来源:', ''); + out[i].pubDate = new Date(full.find('.news-info span:last-of-type').text().replace('时间:', '')).toUTCString(); ctx.cache.set(out[i].link, JSON.stringify(out[i])); } } diff --git a/lib/routes/namoc/specials.js b/lib/routes/namoc/specials.js index 56193170c1..b23c685dcc 100644 --- a/lib/routes/namoc/specials.js +++ b/lib/routes/namoc/specials.js @@ -8,9 +8,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('div.inner div.list li') - .slice(0, 5) - .get(); + const list = $('div.inner div.list li').slice(0, 5).get(); const out = await Promise.all( list.map(async (item) => { diff --git a/lib/routes/natgeo/natgeo.js b/lib/routes/natgeo/natgeo.js index 144ce23663..b2ecd05c5b 100644 --- a/lib/routes/natgeo/natgeo.js +++ b/lib/routes/natgeo/natgeo.js @@ -29,13 +29,7 @@ async function load(link) { const dt = new Date(); dt.setMonth(MonthMap[dtStr[0].toUpperCase()]); dt.setDate(dtStr[1]); - let description = - $('article') - .first() - .html() + - $('article') - .eq(1) - .html(); + let description = $('article').first().html() + $('article').eq(1).html(); if (/photo/.test(link)) { description = $('#content-album').html() + description; } @@ -52,12 +46,7 @@ module.exports = async (ctx) => { const res = await got.get(url); const $ = cheerio.load(res.data); - const urlList = Array.prototype.map.call($('.article-link-w100').find('.read-btn'), (i) => - $(i) - .find('a[href]') - .first() - .attr('href') - ); + const urlList = Array.prototype.map.call($('.article-link-w100').find('.read-btn'), (i) => $(i).find('a[href]').first().attr('href')); const count = []; for (let i = 0; i < Math.min(urlList.length, 10); i++) { diff --git a/lib/routes/nature/highlight.js b/lib/routes/nature/highlight.js index 35c5335aa3..9e7b2805f5 100644 --- a/lib/routes/nature/highlight.js +++ b/lib/routes/nature/highlight.js @@ -18,10 +18,7 @@ module.exports = async (ctx) => { const time = $('time').text(); let author; if ($('.js-list-authors-3 li').length > 3) { - author = - $('.js-list-authors-3 li') - .slice(0, 1) - .text() + ' et al.'; + author = $('.js-list-authors-3 li').slice(0, 1).text() + ' et al.'; } else { author = $('.js-list-authors-3 li').text(); } diff --git a/lib/routes/nature/news.js b/lib/routes/nature/news.js index 69ece554f0..855e36f489 100644 --- a/lib/routes/nature/news.js +++ b/lib/routes/nature/news.js @@ -18,10 +18,7 @@ module.exports = async (ctx) => { const time = $('time').text(); let author; if ($('.js-list-authors-3 li').length > 3) { - author = - $('.js-list-authors-3 li') - .slice(0, 1) - .text() + ' et al.'; + author = $('.js-list-authors-3 li').slice(0, 1).text() + ' et al.'; } else { author = $('.js-list-authors-3 li').text(); } diff --git a/lib/routes/nature/research.js b/lib/routes/nature/research.js index e8595e84e8..616ecb394b 100644 --- a/lib/routes/nature/research.js +++ b/lib/routes/nature/research.js @@ -41,10 +41,7 @@ module.exports = async (ctx) => { const time = $('time').text(); let author; if ($('.js-list-authors-3 li').length > 3) { - author = - $('.js-list-authors-3 li') - .slice(0, 1) - .text() + ' et al.'; + author = $('.js-list-authors-3 li').slice(0, 1).text() + ' et al.'; } else { author = $('.js-list-authors-3 li').text(); } @@ -78,7 +75,7 @@ module.exports = async (ctx) => { } // Info [obtain form address of each page] const subject = itemCapture('li.c-article-subject-list__subject > a') - .map(function() { + .map(function () { const link = $(this).attr('href'); const name = $(this).text(); if (name !== '') { diff --git a/lib/routes/nbd/article.js b/lib/routes/nbd/article.js index dce84262fb..e343d37e23 100644 --- a/lib/routes/nbd/article.js +++ b/lib/routes/nbd/article.js @@ -12,26 +12,14 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(response.data); - const $list = $('li.u-news-title') - .slice(0, 15) - .get(); - const description = $('head title') - .text() - .trim(); + const $list = $('li.u-news-title').slice(0, 15).get(); + const description = $('head title').text().trim(); const resultItem = await Promise.all( $list.map(async (item) => { - const title = $(item) - .find('a') - .text() - .trim(); - const pubDate = $(item) - .find('span') - .text() - .trim(); - const itemUrl = $(item) - .find('a') - .attr('href'); + const title = $(item).find('a').text().trim(); + const pubDate = $(item).find('span').text().trim(); + const itemUrl = $(item).find('a').attr('href'); const single = { title: title, diff --git a/lib/routes/netease/ds.js b/lib/routes/netease/ds.js index f9be3f6c68..0505a6044b 100644 --- a/lib/routes/netease/ds.js +++ b/lib/routes/netease/ds.js @@ -28,12 +28,7 @@ module.exports = async (ctx) => { title: title, link: a.attr('href'), description: desc.html(), - pubDate: date( - item - .find('time.userbar__time') - .text() - .trim() - ), + pubDate: date(item.find('time.userbar__time').text().trim()), }; }) .get(); diff --git a/lib/routes/netease/open/vip.js b/lib/routes/netease/open/vip.js index 738ae4ed1a..1d6c1e84a8 100644 --- a/lib/routes/netease/open/vip.js +++ b/lib/routes/netease/open/vip.js @@ -25,12 +25,8 @@ module.exports = async (ctx) => { const out = await Promise.all( list.map(async (item) => { const $ = cheerio.load(item); - const title = $('.ltxt') - .text() - .trim(); - const link = $('a.item') - .attr('href') - .split('?')[0]; + const title = $('.ltxt').text().trim(); + const link = $('a.item').attr('href').split('?')[0]; const cache = await ctx.cache.get(link); if (cache) { diff --git a/lib/routes/nfmovies/index.js b/lib/routes/nfmovies/index.js index 2dde8aea59..9ec7ec1e2d 100644 --- a/lib/routes/nfmovies/index.js +++ b/lib/routes/nfmovies/index.js @@ -32,7 +32,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const items = []; - $('.col-md-2').each(function() { + $('.col-md-2').each(function () { const item = $(this); const link = mv_slot.replace( 'UID', diff --git a/lib/routes/nga/post.js b/lib/routes/nga/post.js index 24586424ed..bba6ac6951 100644 --- a/lib/routes/nga/post.js +++ b/lib/routes/nga/post.js @@ -47,12 +47,7 @@ module.exports = async (ctx) => { const description = eraseTag(pipeImg(eraseQuote(content.html() || ''))); const postId = content.attr('id'); const link = getPageUrl(tid, pageId, postId); - const pubDate = new Date( - post - .find('.postInfo > span') - .first() - .text() - ).toUTCString(); + const pubDate = new Date(post.find('.postInfo > span').first().text()).toUTCString(); return { title, diff --git a/lib/routes/nintendo/direct.js b/lib/routes/nintendo/direct.js index d3d5a1ca14..bccacaeea6 100644 --- a/lib/routes/nintendo/direct.js +++ b/lib/routes/nintendo/direct.js @@ -9,21 +9,15 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); - const list = $('.news-tiles li') - .get() - .slice(0, 9); + const list = $('.news-tiles li').get().slice(0, 9); const result = list.map((item) => { const $ = cheerio.load(item); return { title: $('.b7').html(), - cover: $('img ') - .attr('src') - .replace('../', 'https://www.nintendo.com/nintendo-direct/'), + cover: $('img ').attr('src').replace('../', 'https://www.nintendo.com/nintendo-direct/'), des: $('p').html(), - url: $('a') - .attr('href') - .replace('../', 'https://www.nintendo.com/nintendo-direct/'), + url: $('a').attr('href').replace('../', 'https://www.nintendo.com/nintendo-direct/'), }; }); diff --git a/lib/routes/nintendo/system-update.js b/lib/routes/nintendo/system-update.js index 40dfc28ab2..8ec99582da 100644 --- a/lib/routes/nintendo/system-update.js +++ b/lib/routes/nintendo/system-update.js @@ -7,9 +7,7 @@ module.exports = async (ctx) => { const response = await got.get(url); const $ = cheerio.load(response.data); - const list = $('#latest > .c-heading-lv3') - .toArray() - .slice(1); + const list = $('#latest > .c-heading-lv3').toArray().slice(1); ctx.state.data = { title: 'Nintendo Switch 本体更新情報', @@ -20,7 +18,7 @@ module.exports = async (ctx) => { const matched_date = /(\d+)年(\d+)月(\d+)日/.exec(heading); const update_info = update.nextUntil('.c-heading-lv3'); const update_infos = update_info - .map(function() { + .map(function () { return $(this).html(); }) .get() diff --git a/lib/routes/nogizaka46/news.js b/lib/routes/nogizaka46/news.js index c71682063c..58bd4b7c69 100644 --- a/lib/routes/nogizaka46/news.js +++ b/lib/routes/nogizaka46/news.js @@ -24,19 +24,10 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: item - .find('.title strong a') - .first() - .text(), - description: item - .find('.summary') - .first() - .text(), + title: item.find('.title strong a').first().text(), + description: item.find('.summary').first().text(), link: item.find('.title strong a').attr('href'), - pubDate: item - .find('.date') - .first() - .text(), + pubDate: item.find('.date').first().text(), }; }) .get(), diff --git a/lib/routes/noi/rg-news.js b/lib/routes/noi/rg-news.js index 6604c6662d..3b9d8c987d 100644 --- a/lib/routes/noi/rg-news.js +++ b/lib/routes/noi/rg-news.js @@ -10,19 +10,10 @@ module.exports = async (ctx) => { postList.shift(); const result = await Promise.all( postList.map(async (item) => { - const title = $(item) - .find('a') - .text(); - const link = $(item) - .find('a') - .attr('href') - .replace('..', 'http://rg.noi.cn/admin'); + const title = $(item).find('a').text(); + const link = $(item).find('a').attr('href').replace('..', 'http://rg.noi.cn/admin'); const guid = link; - const pubDate = new Date( - $(item) - .find('.badge') - .text() - ).toUTCString(); + const pubDate = new Date($(item).find('.badge').text()).toUTCString(); const single = { title: title, @@ -42,9 +33,7 @@ module.exports = async (ctx) => { } else { const temp = await got(link, { responseType: 'buffer' }); temp.data = iconv.decode(temp.data, 'gbk'); - single.description = $(temp.data) - .find('.panel-body') - .html(); + single.description = $(temp.data).find('.panel-body').html(); ctx.cache.set(key, { description: single.description, diff --git a/lib/routes/novel/axdzs.js b/lib/routes/novel/axdzs.js index 7d462bb217..db3c30bc3b 100644 --- a/lib/routes/novel/axdzs.js +++ b/lib/routes/novel/axdzs.js @@ -17,13 +17,8 @@ module.exports = async (ctx) => { const title = $('h1').text(); const description = $('meta[name="description"]').attr('content'); - const lastChapter = $('.chapter') - .last() - .children(); - const secondChapter = $('.chapter') - .last() - .prev() - .children(); + const lastChapter = $('.chapter').last().children(); + const secondChapter = $('.chapter').last().prev().children(); const lastChapterUrl = novelUrl + lastChapter.attr('href'); const secondChapterUrl = novelUrl + secondChapter.attr('href'); const lastChapterContent = await ctx.cache.tryGet(lastChapterUrl, async () => { diff --git a/lib/routes/novel/biquge.js b/lib/routes/novel/biquge.js index 85ce877b07..722eb52a57 100644 --- a/lib/routes/novel/biquge.js +++ b/lib/routes/novel/biquge.js @@ -15,15 +15,9 @@ module.exports = async (ctx) => { }); const responseHtml = iconv.decode(response.data, 'GBK'); const $ = cheerio.load(responseHtml); - const title = $('#list>dl>dt>b') - .eq(0) - .text(); - const description = $('#intro>p') - .eq(0) - .text(); - const cover_url = $('#fmimg>img') - .eq(0) - .attr('src'); + const title = $('#list>dl>dt>b').eq(0).text(); + const description = $('#intro>p').eq(0).text(); + const cover_url = $('#fmimg>img').eq(0).attr('src'); const list = $('dd', '#list>dl').slice(0, 9); const chapter_item = list .find('a') diff --git a/lib/routes/novel/booksky.js b/lib/routes/novel/booksky.js index dc04f276be..e2115ac59d 100644 --- a/lib/routes/novel/booksky.js +++ b/lib/routes/novel/booksky.js @@ -21,9 +21,7 @@ module.exports = async (ctx) => { const list = $('tr[class=b]').attr('height', '25'); - const title = $('font') - .attr('color', 'red') - .text(); + const title = $('font').attr('color', 'red').text(); ctx.state.data = { title: title, @@ -36,20 +34,9 @@ module.exports = async (ctx) => { item = $(item); return { title: item.find('.s').text(), - description: item - .find('.t') - .eq(1) - .text(), - pubDate: new Date( - item - .find('.t') - .eq(2) - .text() - ).toUTCString(), - link: `http://booksky.so/${item - .find('.s') - .children('a') - .attr('href')}`, + description: item.find('.t').eq(1).text(), + pubDate: new Date(item.find('.t').eq(2).text()).toUTCString(), + link: `http://booksky.so/${item.find('.s').children('a').attr('href')}`, }; }) .get(), diff --git a/lib/routes/novel/dcrsw.js b/lib/routes/novel/dcrsw.js index 5bca442d5b..34d9f5f9b2 100644 --- a/lib/routes/novel/dcrsw.js +++ b/lib/routes/novel/dcrsw.js @@ -15,13 +15,9 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); - const title = $('h1.book-name') - .children() - .text(); + const title = $('h1.book-name').children().text(); const description = $('div.book-detail').text(); - const chapters = $('.col-md-6') - .slice(0, count) - .get(); + const chapters = $('.col-md-6').slice(0, count).get(); const results = await Promise.all( chapters.map(async (item) => { const $ = cheerio.load(item); @@ -39,11 +35,7 @@ module.exports = async (ctx) => { result += $('div.cont-text').html(); // 如果有下一页则访问下一页 if ($('a:contains("下一页")').length > 0) { - temp = - baseUrl + - $('a:contains("下一页")') - .last() - .attr('href'); + temp = baseUrl + $('a:contains("下一页")').last().attr('href'); } else { temp = ''; } diff --git a/lib/routes/novel/shuquge.js b/lib/routes/novel/shuquge.js index bdf2cffd48..4d89ae654e 100644 --- a/lib/routes/novel/shuquge.js +++ b/lib/routes/novel/shuquge.js @@ -15,13 +15,9 @@ module.exports = async (ctx) => { }); const responseHtml = iconv.decode(response.data, 'utf-8'); const $ = cheerio.load(responseHtml); - const title = $('.listmain>dl>dt') - .eq(0) - .text(); + const title = $('.listmain>dl>dt').eq(0).text(); const description = $('.intro').text(); - const cover_url = $('.cover>img') - .eq(0) - .attr('src'); + const cover_url = $('.cover>img').eq(0).attr('src'); const list = $('.listmain dd').slice(0, 9); const chapter_item = list .find('a') diff --git a/lib/routes/novel/wenxuemi.js b/lib/routes/novel/wenxuemi.js index 7d33e65357..3473781317 100644 --- a/lib/routes/novel/wenxuemi.js +++ b/lib/routes/novel/wenxuemi.js @@ -19,9 +19,7 @@ module.exports = async (ctx) => { const responseHtml = iconv.decode(response.data, 'GBK'); const $ = cheerio.load(responseHtml); - const title = $('h2', '.block_txt2') - .find('a') - .text(); + const title = $('h2', '.block_txt2').find('a').text(); const description = $('.intro_info').text(); const cover_url = $('img', '.block_img2').attr('src'); const list = $('li', '.chapter').slice(0, 5); @@ -46,12 +44,7 @@ module.exports = async (ctx) => { description: res.html(), link: link, }; - if ( - res - .text() - .slice(0, 10) - .includes('正在手打中') === false - ) { + if (res.text().slice(0, 10).includes('正在手打中') === false) { ctx.cache.set(link, JSON.stringify(resultItem)); } } diff --git a/lib/routes/novel/zhaishuyuan.js b/lib/routes/novel/zhaishuyuan.js index 72efaaad1b..aaefaedf95 100644 --- a/lib/routes/novel/zhaishuyuan.js +++ b/lib/routes/novel/zhaishuyuan.js @@ -29,10 +29,7 @@ module.exports = async (ctx) => { content.find('div').remove(); const description = content.html(); const spanList = $('.title > span'); - const author = spanList - .eq(0) - .find('a') - .text(); + const author = spanList.eq(0).find('a').text(); const pubDate = spanList.eq(2).text(); return { title, link, description, author, pubDate }; }) diff --git a/lib/routes/nowcoder/discuss.js b/lib/routes/nowcoder/discuss.js index 388ad7609b..fd50ceb977 100644 --- a/lib/routes/nowcoder/discuss.js +++ b/lib/routes/nowcoder/discuss.js @@ -17,16 +17,10 @@ module.exports = async (ctx) => { const order_name = $('li.selected a').text(); const list = $('li.clearfix') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('div.discuss-main.clearfix a') - .text() - .trim() - .replace('\n', ' '), - link: $(this) - .find('div.discuss-main.clearfix a[rel]') - .attr('href'), + title: $(this).find('div.discuss-main.clearfix a').text().trim().replace('\n', ' '), + link: $(this).find('div.discuss-main.clearfix a[rel]').attr('href'), }; return info; }) @@ -45,9 +39,7 @@ module.exports = async (ctx) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const date_value = $('span.post-time') - .text() - .split(' ')[1]; + const date_value = $('span.post-time').text().split(' ')[1]; const description = $('.nc-post-content').html(); diff --git a/lib/routes/nvidia/webdriverupdate.js b/lib/routes/nvidia/webdriverupdate.js index e8a9b01f2d..dc9ac44862 100644 --- a/lib/routes/nvidia/webdriverupdate.js +++ b/lib/routes/nvidia/webdriverupdate.js @@ -11,7 +11,7 @@ module.exports = async (ctx) => { const list = plist.parse(res.data).updates; - const resultItem = list.map(function(i) { + const resultItem = list.map(function (i) { const item = {}; item.title = i.version; diff --git a/lib/routes/nytimes/index.js b/lib/routes/nytimes/index.js index cc6dfa33de..4306b9fa81 100644 --- a/lib/routes/nytimes/index.js +++ b/lib/routes/nytimes/index.js @@ -62,9 +62,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(response); if ($('.dual-btn').length > 0) { hasEnVersion = true; - link = $('.dual-btn a') - .last() - .attr().href; + link = $('.dual-btn a').last().attr().href; response = await ctx.cache.tryGet(`nyt: ${link}`, async () => { const response = await got.get(link); diff --git a/lib/routes/nytimes/utils.js b/lib/routes/nytimes/utils.js index 54cec7d96e..2ec7f6806a 100644 --- a/lib/routes/nytimes/utils.js +++ b/lib/routes/nytimes/utils.js @@ -7,9 +7,7 @@ const ProcessImage = ($, e) => { const caption = $(e).find('figcaption'); - cover += `${$(caption[0]) - .text() - .trim()}`; + cover += `${$(caption[0]).text().trim()}`; return cover; }; @@ -23,9 +21,7 @@ const ProcessFeed = (data, hasEnVersion = false) => { // 处理 www.nytimes.com if (hasEnVersion) { content = $('section[name="articleBody"]'); - result.title = `「英」${$('h1') - .text() - .trim()}`; + result.title = `「英」${$('h1').text().trim()}`; result.author = $('article#story span[itemprop="name"]').text(); // 处理封面图片 diff --git a/lib/routes/oilprice/index.js b/lib/routes/oilprice/index.js index 418e45f575..1c7dd586ab 100644 --- a/lib/routes/oilprice/index.js +++ b/lib/routes/oilprice/index.js @@ -11,14 +11,10 @@ module.exports = async (ctx) => { responseType: 'buffer', }); const $ = cheerio.load(iconv.decode(response.data, 'gb2312')); - const $list = $('.content') - .eq(0) - .find('table tbody tr'); + const $list = $('.content').eq(0).find('table tbody tr'); const resultItem = []; let areaName = ''; - const updateTime = $('.time') - .text() - .split(':')[1]; + const updateTime = $('.time').text().split(':')[1]; const labelList = $list .eq(1) .find('td') @@ -27,13 +23,7 @@ module.exports = async (ctx) => { .get(); for (let i = 2; i < $list.length; i++) { - if ( - $list - .eq(i) - .find('td a') - .attr('href') - .includes(`oil.usd-cny.com/${area}.htm`) - ) { + if ($list.eq(i).find('td a').attr('href').includes(`oil.usd-cny.com/${area}.htm`)) { const $item = $list.eq(i); areaName = $item.find('td a').text(); const { description, content } = labelList.reduce( diff --git a/lib/routes/one/index.js b/lib/routes/one/index.js index 2e24547a03..89cbb000bd 100644 --- a/lib/routes/one/index.js +++ b/lib/routes/one/index.js @@ -18,17 +18,9 @@ module.exports = async (ctx) => { const out = await Promise.all( list.map(async (item, i) => { - const url = $(item) - .find('a') - .attr('href'); + const url = $(item).find('a').attr('href'); const single = { - title: - itemMap[i] + - $(item) - .find('a') - .text() - .replace(/\s+/g, ' ') - .trim(), + title: itemMap[i] + $(item).find('a').text().replace(/\s+/g, ' ').trim(), link: url, description: '', }; diff --git a/lib/routes/oschina/news.js b/lib/routes/oschina/news.js index f76168120e..32d2edff79 100644 --- a/lib/routes/oschina/news.js +++ b/lib/routes/oschina/news.js @@ -81,9 +81,7 @@ module.exports = async (ctx) => { const content = cheerio.load(detail.data); content('.ad-wrap').remove(); item.description = content('#articleContent').html(); - item.author = content('a.__user') - .find('span') - .text(); + item.author = content('a.__user').find('span').text(); ctx.cache.set(key, item.description); } } diff --git a/lib/routes/owspace/read.js b/lib/routes/owspace/read.js index c83087588d..f3da24461a 100644 --- a/lib/routes/owspace/read.js +++ b/lib/routes/owspace/read.js @@ -58,10 +58,7 @@ const generateFullText = async (item) => { const audioContainer = content.find('.fmCon').removeAttr('style'); // generate audio player - $('') - .attr('src', item.fm) - .attr('preload', 'metadata') - .prependTo(audioContainer); + $('').attr('src', item.fm).attr('preload', 'metadata').prependTo(audioContainer); content.find('.fmCon>.graphic').remove(); content.find('.fmCon>.fmDetail').remove(); diff --git a/lib/routes/p-articles/contributors.js b/lib/routes/p-articles/contributors.js index 2554416d17..34f5fe79fd 100644 --- a/lib/routes/p-articles/contributors.js +++ b/lib/routes/p-articles/contributors.js @@ -14,12 +14,9 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const list = $('div.contect_box_05in > a') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h3') - .text() - .trim(), + title: $(this).find('h3').text().trim(), link: url.resolve(host, $(this).attr('href')), }; return info; diff --git a/lib/routes/p-articles/section.js b/lib/routes/p-articles/section.js index 0fc3a30c2f..3c829561ea 100644 --- a/lib/routes/p-articles/section.js +++ b/lib/routes/p-articles/section.js @@ -21,12 +21,9 @@ module.exports = async (ctx) => { }; const list = $('div.contect_box_04 > a') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h1') - .text() - .trim(), + title: $(this).find('h1').text().trim(), link: url.resolve(host, $(this).attr('href')), }; return info; diff --git a/lib/routes/p-articles/utils.js b/lib/routes/p-articles/utils.js index c5fff630a5..3b284e5771 100644 --- a/lib/routes/p-articles/utils.js +++ b/lib/routes/p-articles/utils.js @@ -7,13 +7,9 @@ const ProcessFeed = (ctx, info, data) => { const $ = cheerio.load(data); - const author = $('div.detail_title_02 > h4 > a:nth-child(2)') - .text() - .trim(); + const author = $('div.detail_title_02 > h4 > a:nth-child(2)').text().trim(); - const date_value = $('div.detail_title_02 > h4 ') - .text() - .trim(); + const date_value = $('div.detail_title_02 > h4 ').text().trim(); const description = $('div.detail_contect_01').html(); diff --git a/lib/routes/paidai/bbs.js b/lib/routes/paidai/bbs.js index 8f84f099d4..7330fa8712 100644 --- a/lib/routes/paidai/bbs.js +++ b/lib/routes/paidai/bbs.js @@ -16,17 +16,11 @@ module.exports = async (ctx) => { const list = $('#index_topic_list ul li') .slice(0, 11) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('span.m2-li-r-1 a') - .attr('title'), - link: $(this) - .find('span.m2-li-r-1 a') - .attr('href'), - date: $(this) - .find('span.m2-li-r-2') - .text(), + title: $(this).find('span.m2-li-r-1 a').attr('title'), + link: $(this).find('span.m2-li-r-1 a').attr('href'), + date: $(this).find('span.m2-li-r-2').text(), }; return info; }) diff --git a/lib/routes/paidai/index.js b/lib/routes/paidai/index.js index 3084232d06..c1c4147366 100644 --- a/lib/routes/paidai/index.js +++ b/lib/routes/paidai/index.js @@ -16,18 +16,11 @@ module.exports = async (ctx) => { const list = $('#topic_list ul li') .slice(0, 11) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a.i_title') - .attr('title'), - link: $(this) - .find('div.li_1') - .find('a.i_title') - .attr('href'), - date: $(this) - .find('em.li_s') - .text(), + title: $(this).find('a.i_title').attr('title'), + link: $(this).find('div.li_1').find('a.i_title').attr('href'), + date: $(this).find('em.li_s').text(), }; return info; }) diff --git a/lib/routes/paidai/news.js b/lib/routes/paidai/news.js index 3db01569b6..1a2af4d1c9 100644 --- a/lib/routes/paidai/news.js +++ b/lib/routes/paidai/news.js @@ -16,18 +16,11 @@ module.exports = async (ctx) => { const list = $('.news_list ul.list>li') .slice(0, 11) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h3 a') - .attr('title'), - link: $(this) - .find('h3') - .find('a') - .attr('href'), - date: $(this) - .find('.post_info') - .text(), + title: $(this).find('h3 a').attr('title'), + link: $(this).find('h3').find('a').attr('href'), + date: $(this).find('.post_info').text(), }; return info; }) diff --git a/lib/routes/paidai/utils.js b/lib/routes/paidai/utils.js index f8cfe5f8d1..8893c9b066 100644 --- a/lib/routes/paidai/utils.js +++ b/lib/routes/paidai/utils.js @@ -10,9 +10,7 @@ const ProcessFeed = async (info) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const description = $('#topic_content') - .html() - .trim(); + const description = $('#topic_content').html().trim(); const single = { title: title, diff --git a/lib/routes/pcr/news-tw.js b/lib/routes/pcr/news-tw.js index f7d4de0e3a..89d570a8af 100644 --- a/lib/routes/pcr/news-tw.js +++ b/lib/routes/pcr/news-tw.js @@ -15,12 +15,8 @@ module.exports = async (ctx) => { const $ = cheerio.load(htmlString); $('.news_con h2 > span').remove(); - const time = $('.news_con h2') - .text() - .trim(); - $('.news_con section h4') - .first() - .remove(); + const time = $('.news_con h2').text().trim(); + $('.news_con section h4').first().remove(); const content = $('.news_con section'); return { diff --git a/lib/routes/pcr/news.js b/lib/routes/pcr/news.js index 691db8d913..0869ed4208 100644 --- a/lib/routes/pcr/news.js +++ b/lib/routes/pcr/news.js @@ -22,10 +22,7 @@ module.exports = async (ctx) => { return { title: item.find('h4').text(), description: `${item.find('.description p').text()}
`, - link: item - .find('a') - .first() - .attr('href'), + link: item.find('a').first().attr('href'), pubDate: item.find('.time').text(), }; }) diff --git a/lib/routes/pediy/topic.js b/lib/routes/pediy/topic.js index f165b6bfe8..01f39d9cda 100644 --- a/lib/routes/pediy/topic.js +++ b/lib/routes/pediy/topic.js @@ -61,12 +61,7 @@ module.exports = async (ctx) => { .map(async (_, elem) => { const subject = $('.subject a', elem).eq(1); - const pubDate = pediyUtils.dateParser( - $('.date', elem) - .eq(0) - .text(), - 8 - ); + const pubDate = pediyUtils.dateParser($('.date', elem).eq(0).text(), 8); const link = `${baseUrl}${subject.attr('href')}`; const key = `pediy: ${link}`; @@ -84,7 +79,7 @@ module.exports = async (ctx) => { $('.card') .eq(0) .find('.message img') - .each(function(_, item) { + .each(function (_, item) { item = $(item); const src = item.attr('src'); @@ -94,10 +89,7 @@ module.exports = async (ctx) => { item.attr('referrerpolicy', 'no-referrer'); }); - description = $('.card') - .eq(0) - .find('.message') - .html(); + description = $('.card').eq(0).find('.message').html(); ctx.cache.set(key, description); } diff --git a/lib/routes/people/env.js b/lib/routes/people/env.js index c1b9bdc577..a6c35389ac 100644 --- a/lib/routes/people/env.js +++ b/lib/routes/people/env.js @@ -21,14 +21,10 @@ module.exports = async (ctx) => { const list = $('div.headingNews div.hdNews.clearfix') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('strong > a') - .text(), - link: $(this) - .find('strong > a') - .attr('href'), + title: $(this).find('strong > a').text(), + link: $(this).find('strong > a').attr('href'), }; return info; }) @@ -50,17 +46,13 @@ module.exports = async (ctx) => { response.data = iconv.decode(response.data, 'gbk'); const $ = cheerio.load(response.data); - let date = $('.clearfix.w1000_320.text_title .box01 .fl') - .text() - .split(/\s+/); + let date = $('.clearfix.w1000_320.text_title .box01 .fl').text().split(/\s+/); if (date.length > 0) { date = date[0].replace(/(年|月)/g, '/').replace('日', ' ') + ':00'; } else { date = new Date(); } - const description = $('div#rwb_zw') - .html() - .trim(); + const description = $('div#rwb_zw').html().trim(); const single = { title: title, diff --git a/lib/routes/people/opinion.js b/lib/routes/people/opinion.js index cb56fa272f..1254519aaa 100644 --- a/lib/routes/people/opinion.js +++ b/lib/routes/people/opinion.js @@ -21,17 +21,11 @@ module.exports = async (ctx) => { const list = $('ul.list_14.clearfix li') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), - date: $(this) - .find('i') - .text(), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), + date: $(this).find('i').text(), }; return info; }) @@ -54,9 +48,7 @@ module.exports = async (ctx) => { response.data = iconv.decode(response.data, 'gbk'); const $ = cheerio.load(response.data); - const description = $('div.fl.text_con_left') - .html() - .trim(); + const description = $('div.fl.text_con_left').html().trim(); const single = { title: title, diff --git a/lib/routes/people/xjpjh.js b/lib/routes/people/xjpjh.js index c79bf5d011..e0ec0f7f83 100644 --- a/lib/routes/people/xjpjh.js +++ b/lib/routes/people/xjpjh.js @@ -27,14 +27,10 @@ module.exports = async (ctx) => { const list = $('ul.list_14.p1_2.clearfix li') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('a') - .text(), - link: $(this) - .find('a') - .attr('href'), + title: $(this).find('a').text(), + link: $(this).find('a').attr('href'), }; return info; }) @@ -52,9 +48,7 @@ module.exports = async (ctx) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const description = $('div.d2txt_con.clearfix') - .html() - .trim(); + const description = $('div.d2txt_con.clearfix').html().trim(); const single = { title: title, diff --git a/lib/routes/pgyer/app.js b/lib/routes/pgyer/app.js index 0e4ec431a0..4fb01ce4fa 100644 --- a/lib/routes/pgyer/app.js +++ b/lib/routes/pgyer/app.js @@ -42,9 +42,7 @@ module.exports = async (ctx) => { $('head > link') .toArray() .forEach((item) => { - const cssName = $(item) - .attr('href') - .split('/'); + const cssName = $(item).attr('href').split('/'); cssName[cssName.length - 1].split('.').forEach((val) => { Object.keys(indexOfEle).forEach((item) => { if (item === val) { @@ -55,36 +53,17 @@ module.exports = async (ctx) => { }); const appName = $(`${indexOfEle[pageTemplate].appName}`).text(); const appIntro = $(`${indexOfEle[pageTemplate].appIntro}`).text(); - const version = $(`${indexOfEle[pageTemplate].version}`) - .children('li') - .eq(0) - .text(); - const appSize = $(`${indexOfEle[pageTemplate].appSize}`) - .children('li') - .eq(1) - .text() - .slice(3); + const version = $(`${indexOfEle[pageTemplate].version}`).children('li').eq(0).text(); + const appSize = $(`${indexOfEle[pageTemplate].appSize}`).children('li').eq(1).text().slice(3); const appImg = $(`${indexOfEle[pageTemplate].appImg}`) .toArray() - .reduce( - (acc, curr) => - (acc += ``), - '' - ); - let appStatus = $(`${indexOfEle[pageTemplate].appStatus}`) - .text() - .trim(); + .reduce((acc, curr) => (acc += ``), ''); + let appStatus = $(`${indexOfEle[pageTemplate].appStatus}`).text().trim(); if (appStatus === '点击安装') { appStatus = '可下载安装'; } - let updateIntro = $(`${indexOfEle[pageTemplate].updateIntro}`) - .text() - .trim() - .slice(4); + let updateIntro = $(`${indexOfEle[pageTemplate].updateIntro}`).text().trim().slice(4); if (updateIntro === '') { updateIntro = '暂无更新内容'; } diff --git a/lib/routes/pianyuan/app.js b/lib/routes/pianyuan/app.js index e7cc2fef4a..c4fd09b85e 100644 --- a/lib/routes/pianyuan/app.js +++ b/lib/routes/pianyuan/app.js @@ -22,20 +22,14 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const items = []; - $('#main-container > div > div.col-md-10 > table > tbody > tr').each(function(i, item) { - const link = $(item) - .find('td.dt.prel.nobr > a') - .attr('href'); - const text = $(item) - .find('td.dt.prel.nobr > a') - .text(); + $('#main-container > div > div.col-md-10 > table > tbody > tr').each(function (i, item) { + const link = $(item).find('td.dt.prel.nobr > a').attr('href'); + const text = $(item).find('td.dt.prel.nobr > a').text(); const description = $(item) .find('td.dt.prel.nobr') .text() .replace(/^\s+|\s+$/g, ''); - const size = $(item) - .find('td:nth-child(2)') - .text(); + const size = $(item).find('td:nth-child(2)').text(); const description_simple = description.substr(0, description.indexOf('主演')).replace(text, ''); diff --git a/lib/routes/piapro/public.js b/lib/routes/piapro/public.js index 2c25f0920a..8d4864025e 100644 --- a/lib/routes/piapro/public.js +++ b/lib/routes/piapro/public.js @@ -20,21 +20,13 @@ module.exports = async (ctx) => { const list_response = await got.get(url); const $ = cheerio.load(list_response.data); - const type_name = $('#top_titlebox img') - .first() - .attr('alt'); + const type_name = $('#top_titlebox img').first().attr('alt'); const category_name = $('#_filterbox_category .name').text(); const tag_name = $('#_filterbox_character .name').text(); const list = $(selectors[type]) - .map(function() { - return ( - base + - $(this) - .find('a') - .first() - .attr('href') - ); + .map(function () { + return base + $(this).find('a').first().attr('href'); }) .toArray(); diff --git a/lib/routes/piapro/user.js b/lib/routes/piapro/user.js index 221ba0e36e..4d79c43302 100644 --- a/lib/routes/piapro/user.js +++ b/lib/routes/piapro/user.js @@ -17,14 +17,8 @@ module.exports = async (ctx) => { const user_description = $('#main_name p').text(); const list = $('#itemcont .i_main') - .map(function() { - return ( - base + - $(this) - .find('a') - .last() - .attr('href') - ); + .map(function () { + return base + $(this).find('a').last().attr('href'); }) .toArray(); diff --git a/lib/routes/pigtails/index.js b/lib/routes/pigtails/index.js index 4b6844363c..416af3e3ea 100644 --- a/lib/routes/pigtails/index.js +++ b/lib/routes/pigtails/index.js @@ -16,10 +16,7 @@ module.exports = async (ctx) => { const items = []; $('.posts > .post > a').each((idx, item) => { const $item = $(item); - const img_url = $('.thumb', item) - .attr('style') - .split(')')[0] - .split('(')[1]; + const img_url = $('.thumb', item).attr('style').split(')')[0].split('(')[1]; items.push({ title: $item.text(), description: ``, diff --git a/lib/routes/pingwest/status.js b/lib/routes/pingwest/status.js index 3a3944064b..4f88a278d5 100644 --- a/lib/routes/pingwest/status.js +++ b/lib/routes/pingwest/status.js @@ -20,10 +20,7 @@ module.exports = async (ctx) => { const rightNode = $item('.news-info'); const tag = rightNode.find('.item-tag-list').text(); const title = rightNode.find('.title').text(); - const link = rightNode - .find('a') - .last() - .attr('href'); + const link = rightNode.find('a').last().attr('href'); const description = rightNode.text(); return { title: title || tag, diff --git a/lib/routes/pingwest/utils.js b/lib/routes/pingwest/utils.js index 730d3f0e16..c55dee83b7 100644 --- a/lib/routes/pingwest/utils.js +++ b/lib/routes/pingwest/utils.js @@ -11,14 +11,8 @@ const statusListParser = ($) => { .map((_, ele) => ``) .get() .join('
'); - const link = mainNode - .find('.content a') - .first() - .attr('href'); - const content = mainNode - .text() - .trim() - .replace(/展开全文$/, ''); + const link = mainNode.find('.content a').first().attr('href'); + const content = mainNode.text().trim().replace(/展开全文$/, ''); return { title: content, link: link.startsWith('http') ? link : `https:${link}`, diff --git a/lib/routes/pixiv/token.js b/lib/routes/pixiv/token.js index 23ceb9a6bc..d8ec96af6e 100644 --- a/lib/routes/pixiv/token.js +++ b/lib/routes/pixiv/token.js @@ -32,7 +32,7 @@ async function getToken() { 'X-Client-Hash': md5(localTime + authorizationInfo.hash_secret), ...maskHeader, }, - }).catch(function() { + }).catch(function () { logger.error('Pixiv login fail.'); }); return response && response.data && response.data.response; diff --git a/lib/routes/ps/ps4updates.js b/lib/routes/ps/ps4updates.js index 9f435b0874..ae99dab80f 100644 --- a/lib/routes/ps/ps4updates.js +++ b/lib/routes/ps/ps4updates.js @@ -19,19 +19,11 @@ module.exports = async (ctx) => { return pubdateString; } const list = $('.layoutRowParsys ul li') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('span.psc-d-block') - .text(), - link: $(this) - .find('a') - .attr('href'), - date: sortDate( - $(this) - .find('span.psc-info-date') - .text() - ), + title: $(this).find('span.psc-d-block').text(), + link: $(this).find('a').attr('href'), + date: sortDate($(this).find('span.psc-info-date').text()), }; return info; }) @@ -61,9 +53,7 @@ module.exports = async (ctx) => { }) ); ctx.state.data = { - title: $('.psc-main-format-style') - .first() - .text(), + title: $('.psc-main-format-style').first().text(), link: link, item: out, }; diff --git a/lib/routes/ps/trophy.js b/lib/routes/ps/trophy.js index f0941cf216..25f88dc500 100644 --- a/lib/routes/ps/trophy.js +++ b/lib/routes/ps/trophy.js @@ -11,18 +11,10 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const list = $('.zebra tr') - .filter(function() { - return ( - $(this) - .find('.progress-bar span') - .text() !== '0%' - ); + .filter(function () { + return $(this).find('.progress-bar span').text() !== '0%'; }) - .map((i, e) => - $(e) - .find('.title') - .attr('href') - ) + .map((i, e) => $(e).find('.title').attr('href')) .get() .slice(0, 3); @@ -48,43 +40,23 @@ module.exports = async (ctx) => { Bronze: '铜', }; return { - title: - item.find('.title').text() + - ' - ' + - $('.page h3') - .eq(0) - .text() - .trim() - .replace(' Trophies', ''), - description: `
${item + title: item.find('.title').text() + ' - ' + $('.page h3').eq(0).text().trim().replace(' Trophies', ''), + description: `
${item .find('.title') .parent() .contents() - .filter(function() { + .filter(function () { return this.nodeType === 3; }) .text() - .trim()}
等级:${ - classMap[ - item - .find('td') - .eq(5) - .find('img') - .attr('title') - ] - }
珍贵度:${item.find('.hover-show .typo-top').text()}`, + .trim()}
等级:${classMap[item.find('td').eq(5).find('img').attr('title')]}
珍贵度:${item.find('.hover-show .typo-top').text()}`, link: 'https://psnprofiles.com' + item.find('.title').attr('href'), pubDate: new Date( +new Date( item .find('.typo-top-date nobr') .contents() - .filter(function() { + .filter(function () { return this.nodeType === 3; }) .text() + diff --git a/lib/routes/psnine/game.js b/lib/routes/psnine/game.js index 4d5a57714e..08b318635e 100644 --- a/lib/routes/psnine/game.js +++ b/lib/routes/psnine/game.js @@ -13,27 +13,12 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const out = $('table tr') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('.title a') - .text(), - link: $(this) - .find('.title a') - .attr('href'), - pubDate: date( - $(this) - .find('.meta') - .text() - ), - description: - $(this) - .find('.title span') - .text() + - ' ' + - $(this) - .find('.twoge') - .text(), + title: $(this).find('.title a').text(), + link: $(this).find('.title a').attr('href'), + pubDate: date($(this).find('.meta').text()), + description: $(this).find('.title span').text() + ' ' + $(this).find('.twoge').text(), }; return info; }) diff --git a/lib/routes/psnine/index.js b/lib/routes/psnine/index.js index 6d1cbffc1c..596d9f7dc9 100644 --- a/lib/routes/psnine/index.js +++ b/lib/routes/psnine/index.js @@ -14,22 +14,12 @@ module.exports = async (ctx) => { const out = $('.list li') .slice(0, 20) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('.title') - .text(), - link: $(this) - .find('.title a') - .attr('href'), - pubDate: date( - $(this) - .find('.meta') - .text() - ), - author: $(this) - .find('.meta a') - .text(), + title: $(this).find('.title').text(), + link: $(this).find('.title a').attr('href'), + pubDate: date($(this).find('.meta').text()), + author: $(this).find('.meta a').text(), }; return info; }) diff --git a/lib/routes/psnine/news.js b/lib/routes/psnine/news.js index fb21a62298..e6aeb099bf 100644 --- a/lib/routes/psnine/news.js +++ b/lib/routes/psnine/news.js @@ -13,22 +13,12 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const out = $('.box li') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('.content') - .text(), - link: $(this) - .find('.touch') - .attr('href'), - pubDate: date( - $(this) - .find('.meta') - .text() - ), - author: $(this) - .find('.meta a') - .text(), + title: $(this).find('.content').text(), + link: $(this).find('.touch').attr('href'), + pubDate: date($(this).find('.meta').text()), + author: $(this).find('.meta a').text(), }; return info; }) diff --git a/lib/routes/psnine/shuzhe.js b/lib/routes/psnine/shuzhe.js index 36bb233d2d..c8268155e0 100644 --- a/lib/routes/psnine/shuzhe.js +++ b/lib/routes/psnine/shuzhe.js @@ -13,25 +13,13 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const out = $('.dd_ul li') - .map(function() { + .map(function () { const info = { - title: $(this) - .find('.dd_title') - .text(), - link: $(this) - .find('.dd_title a') - .attr('href'), - description: $(this) - .find('.dd_status') - .text(), - pubDate: date( - $(this) - .find('.meta') - .text() - ), - author: $(this) - .find('.meta a') - .text(), + title: $(this).find('.dd_title').text(), + link: $(this).find('.dd_title a').attr('href'), + description: $(this).find('.dd_status').text(), + pubDate: date($(this).find('.meta').text()), + author: $(this).find('.meta a').text(), }; return info; }) diff --git a/lib/routes/psnine/trade.js b/lib/routes/psnine/trade.js index 866fd95848..8faf98bbe7 100644 --- a/lib/routes/psnine/trade.js +++ b/lib/routes/psnine/trade.js @@ -13,29 +13,19 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const out = $('.list li') - .map(function() { + .map(function () { const desc = []; $(this) .find('.meta a') - .each(function(i) { + .each(function (i) { desc[i] = $(this).text(); }); const info = { - title: $(this) - .find('.content') - .text(), - link: $(this) - .find('.touch') - .attr('href'), + title: $(this).find('.content').text(), + link: $(this).find('.touch').attr('href'), description: desc.join(' '), - pubDate: date( - $(this) - .find('.meta') - .text() - ), - author: $(this) - .find('.psnnode') - .text(), + pubDate: date($(this).find('.meta').text()), + author: $(this).find('.psnnode').text(), }; return info; }) diff --git a/lib/routes/pubmed/trending.js b/lib/routes/pubmed/trending.js index e777af3165..4a1ebd7fb1 100644 --- a/lib/routes/pubmed/trending.js +++ b/lib/routes/pubmed/trending.js @@ -18,11 +18,7 @@ module.exports = async (ctx) => { const partial = $('p > a').attr('href'); const address = url.resolve(base, partial); const author = $('div.supp > p.desc').text(); - const pubDate = date( - $('div.supp > p.details') - .text() - .split('. ')[1] - ); + const pubDate = date($('div.supp > p.details').text().split('. ')[1]); const item = { title, diff --git a/lib/routes/qidian/forum.js b/lib/routes/qidian/forum.js index 31d7d60f2d..428e6dbd4b 100644 --- a/lib/routes/qidian/forum.js +++ b/lib/routes/qidian/forum.js @@ -23,19 +23,12 @@ module.exports = async (ctx) => { const items = []; for (let i = 0; i < list.length; ++i) { const el = list[i]; - const title = $(el) - .children() - .eq(1) - .find('a'); + const title = $(el).children().eq(1).find('a'); items.push({ title: title.text(), link: `https:${title.attr('href')}`, description: $(el).text(), - pubDate: parseDate( - $(el) - .find('.post-info>span') - .text() - ), + pubDate: parseDate($(el).find('.post-info>span').text()), }); } diff --git a/lib/routes/qtfyfl/category.js b/lib/routes/qtfyfl/category.js index 53b40c0204..22456a4c76 100644 --- a/lib/routes/qtfyfl/category.js +++ b/lib/routes/qtfyfl/category.js @@ -47,18 +47,10 @@ module.exports = async (ctx) => { const list = $('article') .slice(0, 21) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('header') - .find('h2') - .find('a') - .attr('title'), - link: $(this) - .find('header') - .find('h2') - .find('a') - .attr('href'), + title: $(this).find('header').find('h2').find('a').attr('title'), + link: $(this).find('header').find('h2').find('a').attr('href'), }; return info; }) @@ -77,9 +69,7 @@ module.exports = async (ctx) => { const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const description = $('div.txt') - .html() - .trim(); + const description = $('div.txt').html().trim(); const date = $('time').text(); const single = { diff --git a/lib/routes/quantamagazine/archive.js b/lib/routes/quantamagazine/archive.js index 7f292109b4..55c86d53d7 100644 --- a/lib/routes/quantamagazine/archive.js +++ b/lib/routes/quantamagazine/archive.js @@ -49,13 +49,13 @@ module.exports = async (ctx) => { let contents = capture('#postBody').html(); if (contents !== null) { const latex = contents.replace(/\$latex([\s\S]+?)\$/g, ''); - contents = latex.replace(/
?/g, function(omit, src, cap) { + contents = latex.replace(/
?/g, function (omit, src, cap) { const imgUrl = src.replace(/\\([^un])/g, '$1'); const img = ''; const noBS = cap.replace(/\\([^un])/g, '$1'); const removeNL = noBS.replace(/\\n/g, ''); - const caption = removeNL.replace(/\\u([0-9]{1,3}[a-z][0-9]?|[0-9]{4}?)/g, function(omit, s) { + const caption = removeNL.replace(/\\u([0-9]{1,3}[a-z][0-9]?|[0-9]{4}?)/g, function (omit, s) { return String.fromCharCode(parseInt(s, 16)); }); const inset = '
' + img + '
' + caption + '
' + '
'; diff --git a/lib/routes/remote-work/index.js b/lib/routes/remote-work/index.js index 973ca47111..81e0a873b7 100644 --- a/lib/routes/remote-work/index.js +++ b/lib/routes/remote-work/index.js @@ -75,9 +75,7 @@ module.exports = async (ctx) => { await ctx.cache.tryGet('remote-work' + item.link, async () => { const res = await got({ method: 'get', url: url.resolve(root_url, item.link) }); const content = cheerio.load(res.data); - item.description = content('div.container div.main div.job-section') - .first() - .html(); + item.description = content('div.container div.main div.job-section').first().html(); return item; }) ) diff --git a/lib/routes/rsshub/routes.js b/lib/routes/rsshub/routes.js index 62a98ca0c4..76aca40328 100644 --- a/lib/routes/rsshub/routes.js +++ b/lib/routes/rsshub/routes.js @@ -57,19 +57,9 @@ module.exports = async (ctx) => { item.find('.header-anchor').remove(); const titleEle = item.prevAll('h2').eq(0); return { - title: `${titleEle.text().slice(2)} - ${item - .prevAll('h3') - .eq(0) - .text() - .slice(2)}`, + title: `${titleEle.text().slice(2)} - ${item.prevAll('h3').eq(0).text().slice(2)}`, description: item.html(), - link: `https://docs.rsshub.app/${type}.html#${encodeURIComponent( - titleEle.find('.header-anchor').attr('href') && - titleEle - .find('.header-anchor') - .attr('href') - .slice(1) - )}`, + link: `https://docs.rsshub.app/${type}.html#${encodeURIComponent(titleEle.find('.header-anchor').attr('href') && titleEle.find('.header-anchor').attr('href').slice(1))}`, guid: item.attr('id'), }; }), diff --git a/lib/routes/rsshub/sponsors.js b/lib/routes/rsshub/sponsors.js index 1256f8653a..f44beb85b2 100644 --- a/lib/routes/rsshub/sponsors.js +++ b/lib/routes/rsshub/sponsors.js @@ -10,12 +10,8 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); - const special = $('#special-sponsors') - .next('p') - .find('a'); - const normal = $('#sponsors') - .next('p') - .find('a'); + const special = $('#special-sponsors').next('p').find('a'); + const normal = $('#sponsors').next('p').find('a'); ctx.state.data = { title: 'RSSHub 有新赞助商啦', diff --git a/lib/routes/sciencemag/cover.js b/lib/routes/sciencemag/cover.js index f598a6400f..fdcc17b76f 100644 --- a/lib/routes/sciencemag/cover.js +++ b/lib/routes/sciencemag/cover.js @@ -23,7 +23,7 @@ module.exports = async (ctx) => { .attr('src') .match(/\/covers\/(?\w+)\/(?\d+)\/(?\d+)\//).groups; const url = $('div.media__body > ul > li > a', elem) - .filter(function(_, el) { + .filter(function (_, el) { return $(el).text() === 'Current Issue'; }) .attr('href') diff --git a/lib/routes/sciencemag/current.js b/lib/routes/sciencemag/current.js index b617607544..32885f4f23 100644 --- a/lib/routes/sciencemag/current.js +++ b/lib/routes/sciencemag/current.js @@ -30,9 +30,7 @@ module.exports = async (ctx) => { if (sectionContent !== null) { const sec = cheerio.load(sectionContent); const sectionName = sec('h2').text(); - const sectionList = sec('ul > li > div > div > article > div') - .append(`
${sectionName}
`) - .get(); + const sectionList = sec('ul > li > div > div > article > div').append(`
${sectionName}
`).get(); return sectionList; } return []; diff --git a/lib/routes/sciencemag/early.js b/lib/routes/sciencemag/early.js index 12524a5c28..d7142b6970 100644 --- a/lib/routes/sciencemag/early.js +++ b/lib/routes/sciencemag/early.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { let author; const authorList = $('span.highwire-citation-authors > span.highwire-citation-author') - .map(function(i, el) { + .map(function (i, el) { return $(el).text(); }) .get(); @@ -65,7 +65,7 @@ module.exports = async (ctx) => { } // abs content const abs = itemCapture('div > div.abstract-view > div.section') - .map(function(i, el) { + .map(function (i, el) { return $(el).html(); }) .get() diff --git a/lib/routes/sckjt/news.js b/lib/routes/sckjt/news.js index 30be3322a3..5c27898d6e 100644 --- a/lib/routes/sckjt/news.js +++ b/lib/routes/sckjt/news.js @@ -26,20 +26,9 @@ module.exports = async (ctx) => { .children('h2') .slice(0, 15) .map((_, elem) => ({ - link: - baseUrl + - $(elem) - .children('a') - .attr('href'), - title: $(elem) - .children('a') - .text(), - pubDate: new Date( - $(elem) - .children('span') - .text() - .replace(dateRegex, '$1-$2-$3') - ).toUTCString(), + link: baseUrl + $(elem).children('a').attr('href'), + title: $(elem).children('a').text(), + pubDate: new Date($(elem).children('span').text().replace(dateRegex, '$1-$2-$3')).toUTCString(), })) .get(), }; diff --git a/lib/routes/security/pulses.js b/lib/routes/security/pulses.js index 0c163ac224..21362bb445 100644 --- a/lib/routes/security/pulses.js +++ b/lib/routes/security/pulses.js @@ -11,23 +11,13 @@ module.exports = async (ctx) => { const out = $('div.endless_page_template div.card') .slice(0, 10) - .map(function() { - const author = $(this) - .find('div.card-body small.text-muted') - .text() - .trim() - .split('•')[0]; - const itemUrl = $(this) - .find('h5.card-title > a') - .attr('href'); + .map(function () { + const author = $(this).find('div.card-body small.text-muted').text().trim().split('•')[0]; + const itemUrl = $(this).find('h5.card-title > a').attr('href'); const info = { link: url.resolve(host, itemUrl), - description: $(this) - .find('p.card-text.my-1') - .html(), - title: $(this) - .find('h5.card-title') - .text(), + description: $(this).find('p.card-text.my-1').html(), + title: $(this).find('h5.card-title').text(), author: author, }; return info; diff --git a/lib/routes/segmentfault/channel.js b/lib/routes/segmentfault/channel.js index dac134ff10..a7d0a5cfdf 100644 --- a/lib/routes/segmentfault/channel.js +++ b/lib/routes/segmentfault/channel.js @@ -16,17 +16,11 @@ module.exports = async (ctx) => { const list = $('div.news-item.stream__item.clearfix.mt15') .slice(0, 10) - .map(function() { + .map(function () { const info = { - link: $(this) - .find('div.news__item-info.clearfix a') - .attr('href'), - title: $(this) - .find('div.mb5.mt5 h4') - .text(), - author: $(this) - .find('span.author.pr20 a') - .text(), + link: $(this).find('div.news__item-info.clearfix a').attr('href'), + title: $(this).find('div.mb5.mt5 h4').text(), + author: $(this).find('span.author.pr20 a').text(), }; return info; }) @@ -51,18 +45,13 @@ module.exports = async (ctx) => { if (info.link.indexOf('p') !== -1) { // 分享 description = - $('div.fmt.mb10') - .html() - .trim() + + $('div.fmt.mb10').html().trim() + $('div.content h3') .html() .replace(/href="\//g, `href="${url.resolve(host, '.')}`) .trim(); - const date_list = $('div.news__item-info > p > span') - .text() - .trim() - .split(' '); + const date_list = $('div.news__item-info > p > span').text().trim().split(' '); date_list.shift(); let date_v = ''; if (date_list.length > 1) { @@ -77,10 +66,7 @@ module.exports = async (ctx) => { .html() .replace(/data-src="/g, 'src="https://segmentfault.com') .trim(); - const date_v = $('div.article__authorright > span') - .text() - .trim() - .replace(' ', ''); + const date_v = $('div.article__authorright > span').text().trim().replace(' ', ''); date_value = date_v.substring(0, date_v.length - 2); } diff --git a/lib/routes/shuhui/comics.js b/lib/routes/shuhui/comics.js index e1f3490eb4..6bcdf08123 100644 --- a/lib/routes/shuhui/comics.js +++ b/lib/routes/shuhui/comics.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { Origin: 'https://www.ishuhui.com', Referer: `https://www.ishuhui.com/comics/anime/${id}`, }, - }).then(function(response) { + }).then(function (response) { // 漫画名 const name = response.data.data.name; // 漫画描述 @@ -53,7 +53,7 @@ module.exports = async (ctx) => { Origin: 'https://www.ishuhui.com', Referer: `https://www.ishuhui.com/comics/detail/${lastEpisodeId}`, }, - }).then(function(response) { + }).then(function (response) { const picUrlArray = response.data.data.contentImg; const rssTitle = response.data.data.animeName; const title = response.data.data.title; diff --git a/lib/routes/simonsfoundation/recommend.js b/lib/routes/simonsfoundation/recommend.js index 378caeb93a..19d1792d9f 100644 --- a/lib/routes/simonsfoundation/recommend.js +++ b/lib/routes/simonsfoundation/recommend.js @@ -16,29 +16,11 @@ module.exports = async (ctx) => { description: `Simons Foundation - What We're Reading`, item: $('.o-dated-list__row') .map((index, item) => ({ - title: $(item) - .find('.m-post__title') - .text(), - description: $(item) - .find('.m-post__aside') - .html(), - pubDate: new Date( - $(item) - .find('.o-dated-list__day') - .text() + - ' ' + - $(item) - .find('.o-dated-list__month') - .text() + - ' ' + - $(item) - .find('.o-dated-list__year') - .text() - ).toUTCString(), + title: $(item).find('.m-post__title').text(), + description: $(item).find('.m-post__aside').html(), + pubDate: new Date($(item).find('.o-dated-list__day').text() + ' ' + $(item).find('.o-dated-list__month').text() + ' ' + $(item).find('.o-dated-list__year').text()).toUTCString(), - link: $(item) - .find('.m-post__block-link') - .attr('href'), + link: $(item).find('.m-post__block-link').attr('href'), })) .get(), }; diff --git a/lib/routes/sketch/beta.js b/lib/routes/sketch/beta.js index 6465ff4fab..954f48e8b1 100644 --- a/lib/routes/sketch/beta.js +++ b/lib/routes/sketch/beta.js @@ -13,16 +13,10 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); // 获取版本 - const version = $('small.heading-caption') - .text() - .trim(); + const version = $('small.heading-caption').text().trim(); // 判断是否已发布 - const releaseString = $('.wrapper') - .first() - .find('h1') - .text() - .substr(-8); + const releaseString = $('.wrapper').first().find('h1').text().substr(-8); let isrelease = 0; if (releaseString === 'released') { @@ -33,18 +27,9 @@ module.exports = async (ctx) => { const list = $('.wrapper').first(); // sketch update 提供的时间 年月反了.要重新调整 - const pubday = list - .find('.heading-caption time') - .attr('datetime') - .substr(0, 2); - const pubmonth = list - .find('.heading-caption time') - .attr('datetime') - .substr(3, 2); - const pubyear = list - .find('.heading-caption time') - .attr('datetime') - .substr(-4); + const pubday = list.find('.heading-caption time').attr('datetime').substr(0, 2); + const pubmonth = list.find('.heading-caption time').attr('datetime').substr(3, 2); + const pubyear = list.find('.heading-caption time').attr('datetime').substr(-4); const pubdateString = pubmonth + `-` + pubday + `-` + pubyear; if (isrelease === 1) { @@ -60,10 +45,7 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: `${item - .find('h1') - .first() - .text()}`, + title: `${item.find('h1').first().text()}`, description: `${item.html()}`, link: `https://www.sketch.com/updates/`, pubDate: new Date(pubdateString).toLocaleDateString(), @@ -86,15 +68,8 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: `${item - .find('h1') - .first() - .text()} - - ${item - .find('small.heading-caption') - .first() - .text() - .substr(16, 2)}`, + title: `${item.find('h1').first().text()} + - ${item.find('small.heading-caption').first().text().substr(16, 2)}`, description: content, link: `https://www.sketch.com/beta/`, pubDate: new Date(pubdateString).toLocaleDateString(), diff --git a/lib/routes/sketch/updates.js b/lib/routes/sketch/updates.js index 4f408dc0ef..eb0a6fd7bd 100644 --- a/lib/routes/sketch/updates.js +++ b/lib/routes/sketch/updates.js @@ -21,35 +21,18 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); // sketch update 提供的时间 年月反了.要重新调整 - const pubday = item - .find('section.update-highlights time') - .attr('datetime') - .substr(0, 2); - const pubmonth = item - .find('section.update-highlights time') - .attr('datetime') - .substr(3, 2); - const pubyear = item - .find('section.update-highlights time') - .attr('datetime') - .substr(-4); + const pubday = item.find('section.update-highlights time').attr('datetime').substr(0, 2); + const pubmonth = item.find('section.update-highlights time').attr('datetime').substr(3, 2); + const pubyear = item.find('section.update-highlights time').attr('datetime').substr(-4); const pubdateString = pubmonth + `-` + pubday + `-` + pubyear; return { - title: `${item - .find('h2.update-version-title') - .first() - .text() - .trim()}`, + title: `${item.find('h2.update-version-title').first().text().trim()}`, description: `${item.find('section.update-highlights .lead').html()}
${item.find('section.update-highlights footer').html()}
${item.find('aside.update-details .mask').html()}`, link: `https://www.sketch.com/updates/${item.find('.update-version-title a').attr('href')}`, pubDate: new Date(pubdateString).toLocaleDateString(), - guid: `${item - .find('h2.update-version-title') - .first() - .text() - .trim()}`, + guid: `${item.find('h2.update-version-title').first().text().trim()}`, }; }) .get(), diff --git a/lib/routes/smzdm/haowen.js b/lib/routes/smzdm/haowen.js index e60d0a4400..4557fa30cb 100644 --- a/lib/routes/smzdm/haowen.js +++ b/lib/routes/smzdm/haowen.js @@ -12,17 +12,11 @@ module.exports = async (ctx) => { const list = $('li.feed-row-wide') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h5.z-feed-title a') - .text(), - link: $(this) - .find('h5.z-feed-title a') - .attr('href'), - pubdate: $(this) - .find('span.z-publish-time') - .text(), + title: $(this).find('h5.z-feed-title a').text(), + link: $(this).find('h5.z-feed-title a').attr('href'), + pubdate: $(this).find('span.z-publish-time').text(), }; return info; }) diff --git a/lib/routes/smzdm/haowen_fenlei.js b/lib/routes/smzdm/haowen_fenlei.js index 7fa5c24866..517a3b1a0b 100644 --- a/lib/routes/smzdm/haowen_fenlei.js +++ b/lib/routes/smzdm/haowen_fenlei.js @@ -15,24 +15,15 @@ module.exports = async (ctx) => { const response = await got.get(link); const $ = cheerio.load(response.data); - const title = $('div.crumbs.nav-crumbs') - .text() - .split('>') - .pop(); + const title = $('div.crumbs.nav-crumbs').text().split('>').pop(); const list = $('div.list.post-list') .slice(0, 10) - .map(function() { + .map(function () { const info = { - title: $(this) - .find('h2.item-name a') - .text(), - link: $(this) - .find('h2.item-name a') - .attr('href'), - pubdate: $(this) - .find('span.time') - .text(), + title: $(this).find('h2.item-name a').text(), + link: $(this).find('h2.item-name a').attr('href'), + pubdate: $(this).find('span.time').text(), }; return info; }) diff --git a/lib/routes/smzdm/keyword.js b/lib/routes/smzdm/keyword.js index 3cbb4ab746..11d6345643 100644 --- a/lib/routes/smzdm/keyword.js +++ b/lib/routes/smzdm/keyword.js @@ -27,33 +27,9 @@ module.exports = async (ctx) => { .map((index, item) => { item = $(item); return { - title: `${item - .find('.feed-block-title a') - .eq(0) - .text() - .trim()} - ${item - .find('.feed-block-title a') - .eq(1) - .text() - .trim()}`, - description: `${item - .find('.feed-block-descripe') - .contents() - .eq(2) - .text() - .trim()}
${item - .find('.feed-block-extras span') - .text() - .trim()}
`, - pubDate: formatPubDate( - item - .find('.feed-block-extras') - .contents() - .eq(0) - .text() - .trim(), - 8 - ), + title: `${item.find('.feed-block-title a').eq(0).text().trim()} - ${item.find('.feed-block-title a').eq(1).text().trim()}`, + description: `${item.find('.feed-block-descripe').contents().eq(2).text().trim()}
${item.find('.feed-block-extras span').text().trim()}
`, + pubDate: formatPubDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), 8), link: `${item.find('.feed-block-title a').attr('href')}`, }; }) diff --git a/lib/routes/solidot/_article.js b/lib/routes/solidot/_article.js index c9d4bbaa95..8d74e4ed6e 100644 --- a/lib/routes/solidot/_article.js +++ b/lib/routes/solidot/_article.js @@ -15,17 +15,9 @@ module.exports = async function get_article(url) { const data = response.data; const $ = cheerio.load(data); - const date_raw = $('div.talk_time') - .clone() - .children() - .remove() - .end() - .text(); + const date_raw = $('div.talk_time').clone().children().remove().end().text(); const date_str_zh = date_raw.replace(/^[^`]*发表于(.*分)[^`]*$/g, '$1'); // use [^`] to match \n - const date_str = date_str_zh - .replace(/[年月]/g, '-') - .replace(/时/g, ':') - .replace(/[日分]/g, ''); + const date_str = date_str_zh.replace(/[年月]/g, '-').replace(/时/g, ':').replace(/[日分]/g, ''); let date = new Date(date_str); date.setHours(date.getHours() - 8); date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds())); diff --git a/lib/routes/soundcloud/utils.js b/lib/routes/soundcloud/utils.js index c69c529706..bbbb3684b0 100644 --- a/lib/routes/soundcloud/utils.js +++ b/lib/routes/soundcloud/utils.js @@ -8,11 +8,7 @@ async function load(link) { let result = ''; const tmp = $('noscript article p'); result += `

${tmp.html()}

`; - const embed_url = $('noscript article div') - .first() - .children() - .first() - .attr('content'); + const embed_url = $('noscript article div').first().children().first().attr('content'); result += `