diff --git a/README.md b/README.md index 63e239b287..cc8e6e6d6a 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 特价机票 Flight deals - Google - 谷歌学术关键词更新 +- iMuseum + - 展览信息 diff --git a/docs/README.md b/docs/README.md index f00b78227e..8b72b52e64 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1864,6 +1864,24 @@ nearby: 可选 0 或 1,默认 0 为不包括,是否包括临近机场 1. 简单模式,例如「data visualization」,[https://rsshub.app/google/scholar/data+visualization](https://rsshub.app/google/scholar/data+visualization)。 2. 高级模式,前往 [Google Scholar](https://scholar.google.com/schhp?hl=zh-cn&as_sdt=0,5),点击左上角,选择高级搜索并提交查询。此时 URL 应为:[https://scholar.google.com/scholar?as_q=data+visualization&as_epq=&as_oq=&as_eq=&as_occt=any&as_sauthors=&as_publication=&as_ylo=2018&as_yhi=&hl=zh-CN&as_sdt=0%2C5](https://scholar.google.com/scholar?as_q=data+visualization&as_epq=&as_oq=&as_eq=&as_occt=any&as_sauthors=&as_publication=&as_ylo=2018&as_yhi=&hl=zh-CN&as_sdt=0%2C5),复制`https://scholar.google.com/scholar?`后的所有语句作为本路由的查询参数。例子所对应的完整路由为[https://rsshub.app/google/scholar/as_q=data+visualization&as_epq=&as_oq=&as_eq=&as_occt=any&as_sauthors=&as_publication=&as_ylo=2018&as_yhi=&hl=zh-CN&as_sdt=0%2C5](https://rsshub.app/google/scholar/as_q=data+visualization&as_epq=&as_oq=&as_eq=&as_occt=any&as_sauthors=&as_publication=&as_ylo=2018&as_yhi=&hl=zh-CN&as_sdt=0%2C5)。 +## iMuseum + +### 展览信息 + +举例: [https://rsshub.app/imuseum/shanghai/all](https://rsshub.app/imuseum/shanghai/all) + +路由: `/imuseum/:city/:type` + +参数: + +city,必选,如 shanghai、beijing + +type,可选,不填则默认为 `all` + +| 全部 | 最新 | 热门 | 即将结束 | 即将开始 | 已结束 | +| ---- | ------ | ---- | -------- | -------- | -------- | +| all | latest | hot | end_soon | coming | outdated | + ## Hopper Flight Deals ### Hopper 特价机票 diff --git a/package.json b/package.json index 162e4b6eb6..1f7bbb40eb 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "start": "node index.js", + "dev": "nodemon index.js", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", "format": "eslint \"**/*.js\" --fix && prettier \"**/*.{js,json,md}\" --write", @@ -31,6 +32,7 @@ "eslint-config-prettier": "^3.0.1", "eslint-plugin-prettier": "^2.6.2", "lint-staged": "^7.2.2", + "nodemon": "^1.18.3", "prettier": "^1.14.2", "prettier-check": "^2.0.0", "vuepress": "0.14.2", diff --git a/router.js b/router.js index 5d3f3f1d32..231cf9a848 100755 --- a/router.js +++ b/router.js @@ -419,6 +419,9 @@ router.get('/fir/update/:id', require('./routes/fir/update')); // Google router.get('/google/scholar/:query', require('./routes/google/scholar')); +// 每日环球展览 iMuseum +router.get('/imuseum/:city/:type', require('./routes/imuseum')); + // AppStore router.get('/appstore/update/:country/:id', require('./routes/appstore/update')); diff --git a/routes/imuseum/index.js b/routes/imuseum/index.js new file mode 100644 index 0000000000..2d6881b962 --- /dev/null +++ b/routes/imuseum/index.js @@ -0,0 +1,45 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const config = require('../../config'); + +const baseUrl = 'https://art.icity.ly'; + +/** + * type: ['all', 'latest', 'hot', 'end_soon', 'coming', 'outdated'] + * city: ['shanghai', 'beijing',....] + */ +module.exports = async (ctx) => { + const city = ctx.params.city; + const type = ctx.params.type || 'all'; + const url = `${baseUrl}/${city}/${type}`; + const response = await axios({ + method: 'get', + url: url, + headers: { + 'User-Agent': config.ua, + Referer: url, + }, + }); + const data = response.data; + const $ = cheerio.load(data); + const list = $('.imsm-entries.list li'); + ctx.state.data = { + title: `${$('title').text()}`, + link: url, + description: $('meta[name="description"]').attr('content'), + item: + list && + list + .map((item, index) => { + item = $(index); + const pretitle = item.find('.pretitle').children()[0].prev ? item.find('.pretitle').children()[0].prev.data : ''; + const subtitle = item.find('.subtitle').children()[0].next ? item.find('.subtitle').children()[0].next.data : ''; + return { + title: item.find('div.title').text(), + description: `${subtitle} ${pretitle} `, + link: `${baseUrl}${item.find('a.info').attr('href')}`, + }; + }) + .get(), + }; +};