diff --git a/docs/government.md b/docs/government.md index 8fc8fa002d..bf8f012c46 100644 --- a/docs/government.md +++ b/docs/government.md @@ -232,6 +232,12 @@ pageClass: routes | 贝尔法斯特 | `/embassy/uk/belfast` | | 曼彻斯特 | `/embassy/uk/manchester` | +## 中华人民共和国海关总署 + +### 拍卖信息/海关法规 + + + ## 中华人民共和国商务部 ### 政务公开 diff --git a/docs/program-update.md b/docs/program-update.md index 430f54ef39..133d91b6a8 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -86,6 +86,12 @@ pageClass: routes +## IPSW.me + +### 苹果固件更新-IPSWs/OTAs 版本 + + + ## Minecraft CurseForge ### Mod 更新 diff --git a/docs/university.md b/docs/university.md index aa21254ebc..68b1b433e6 100644 --- a/docs/university.md +++ b/docs/university.md @@ -951,6 +951,10 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet ## 浙江大学 +### 普通栏目 如学术/图片/新闻等 + + + ### 浙大研究生院 diff --git a/lib/router.js b/lib/router.js index f8266a413a..69fefc5743 100644 --- a/lib/router.js +++ b/lib/router.js @@ -696,6 +696,9 @@ router.get('/zaobao/znews/:type?', require('./routes/zaobao/znews')); // Apple router.get('/apple/exchange_repair/:country?', require('./routes/apple/exchange_repair')); +// IPSW.me +router.get('/ipsw/index/:ptype/:pname', require('./routes/ipsw/index')); + // Minecraft CurseForge router.get('/curseforge/files/:project', require('./routes/curseforge/files')); @@ -1026,6 +1029,9 @@ router.get('/gov/suzhou/news/:uid', require('./routes/gov/suzhou/news')); router.get('/gov/suzhou/doc', require('./routes/gov/suzhou/doc')); router.get('/gov/shanxi/rst/:category', require('./routes/gov/shanxi/rst')); +// 中华人民共和国-海关总署 +router.get('/gov/customs/list/:gchannel', require('./routes/gov/customs/list')); + // 中华人民共和国生态环境部 router.get('/gov/mee/gs', require('./routes/gov/mee/gs')); @@ -1229,6 +1235,7 @@ router.get('/psnine/game', require('./routes/psnine/game')); router.get('/psnine/news', require('./routes/psnine/news')); // 浙江大学 +router.get('/zju/list/:type', require('./routes/universities/zju/list')); router.get('/zju/physics/:type', require('./routes/universities/zju/physics')); router.get('/zju/grs/:type', require('./routes/universities/zju/grs')); router.get('/zju/career/:type', require('./routes/universities/zju/career')); diff --git a/lib/routes/gov/customs/list.js b/lib/routes/gov/customs/list.js new file mode 100644 index 0000000000..edcac60157 --- /dev/null +++ b/lib/routes/gov/customs/list.js @@ -0,0 +1,83 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const url = require('url'); +const host = 'http://www.customs.gov.cn/'; +module.exports = async (ctx) => { + const gchannel = ctx.params.gchannel; + let channelName = ``; + let link = `http://www.customs.gov.cn/customs/302249/2476857/302309/index.html`; + + switch (gchannel) { + case 'paimai': + channelName = '拍卖信息'; + link = `http://www.customs.gov.cn/customs/302249/2476857/302309/index.html`; + + break; + case 'fagui': + channelName = '海关法规'; + link = `http://www.customs.gov.cn/customs/302249/302266/08654b53-1.html`; + break; + default: + break; + } + const response = await got({ + method: 'get', + url: link, + header: { + Referer: host, + }, + }); + const $ = cheerio.load(response.data); + + const list = $('.conList_ul li') + .map(function() { + const info = { + title: $(this) + .find('a') + .text(), + link: $(this) + .find('a') + .attr('href'), + date: $(this) + .find('span') + .text(), + }; + return info; + }) + .get(); + const out = await Promise.all( + list.map(async (info) => { + const title = info.title; + const date = info.date; + const itemUrl = url.resolve(host, info.link); + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + const response = await got({ + method: 'get', + url: itemUrl, + header: { + Referer: host, + }, + }); + const $ = cheerio.load(response.data); + $('.easysite-news-operation').remove(); + const description = $('.easysite-news-peruse').html(); + + const single = { + title: title, + link: itemUrl, + description: description, + pubDate: new Date(date).toDateString(), + }; + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: `中国海关-${channelName}`, + link: link, + item: out, + }; +}; diff --git a/lib/routes/ipsw/index.js b/lib/routes/ipsw/index.js new file mode 100644 index 0000000000..f268f56a5b --- /dev/null +++ b/lib/routes/ipsw/index.js @@ -0,0 +1,136 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const url = require('url'); +const host = 'https://ipsw.me/'; +module.exports = async (ctx) => { + const pname = ctx.params.pname; + const ptype = ctx.params.ptype; + let link = `https://ipsw.me/product/` + pname; + if (pname.search(',') === -1) { + // console.log('产品线'); + link = `https://ipsw.me/product/` + pname; + } else { + // console.log('具体产品'); + if (ptype === 'otas') { + // console.log('otas'); + link = `https://ipsw.me/` + ptype + `/` + pname; + } else if (ptype === 'ipsws') { + // console.log('ipsw'); + link = `https://ipsw.me/` + pname; + } + } + // console.log(link); + const response = await got({ + method: 'get', + url: link, + header: { + Referer: host, + }, + }); + const $ = cheerio.load(response.data); + let list = {}; + if (pname.search(',') === -1) { + list = $('.products a') + .map(function() { + const info = { + title: $(this) + .find('img') + .attr('alt'), + link: $(this).attr('href'), + }; + return info; + }) + .get(); + } else { + list = $('.firmware') + .map(function() { + const info = { + title: $(this) + .find('td') + .eq(1) + .text(), + link: replaceurl($(this).attr('onclick')), + date: cdate( + $(this) + .find('td') + .eq(2) + .text() + .trim() + ), + }; + return info; + }) + .get(); + } + + function replaceurl(e) { + e = e.replace("';", ''); + e = e.replace("window.location = '/", host); + return e; + } + // 处理发布日期,以表格第一行的日期为最新的发布日期 + function cdate(e) { + const removeString = e.replace('th', ''); + const removend = removeString.replace('nd', ''); + const replacest = removend.replace('st', ''); + const rdate = replacest.replace(/ /g, ','); + // console.log(rdate); + return rdate; + } + const out = await Promise.all( + list.map(async (info) => { + const title = info.title; + const itemUrl = url.resolve(host, info.link); + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + const response = await got({ + method: 'get', + url: itemUrl, + header: { + Referer: host, + }, + }); + const $ = cheerio.load(response.data); + const description = $('div.selector__wizard').html(); + let removeString; + if (pname.search(',') === -1) { + removeString = $('tr.firmware') + .first() + .find('td') + .eq(2) + .text() + .trim(); + } else { + removeString = $('div.table-responsive table tr') + .first() + .find('td') + .text() + .trim(); + } + // 处理发布日期,以表格第一行的日期为最新的发布日期 + removeString = removeString + .replace('th', '') + .replace('nd', '') + .replace('st', '') + .replace('rd', ''); + const rdate = removeString.replace(/ /g, ','); + const single = { + title: title, + link: itemUrl, + description: description, + pubDate: new Date(rdate).toLocaleDateString(), + guid: title, + }; + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: `${pname} - ${ptype} Released`, + link: link, + description: `查看Apple-${pname}- ${ptype} 固件-是否关闭验证`, + item: out, + }; +}; diff --git a/lib/routes/sketch/beta.js b/lib/routes/sketch/beta.js index 19af54e689..81cf62eaf1 100644 --- a/lib/routes/sketch/beta.js +++ b/lib/routes/sketch/beta.js @@ -12,6 +12,11 @@ module.exports = async (ctx) => { }); const data = response.data; const $ = cheerio.load(data); + // 获取版本 + const version = $('small.heading-caption') + .text() + .trim(); + // console.log(version); // 判断是否已发布 const releaseString = $('.wrapper') .first() @@ -26,7 +31,6 @@ module.exports = async (ctx) => { isrelease = 0; } // console.log(isrelease); - const list = $('.wrapper').first(); // sketch update 提供的时间 年月反了.要重新调整 const pubday = list @@ -64,6 +68,7 @@ module.exports = async (ctx) => { description: `${item.html()}`, link: `https://www.sketch.com/updates/`, pubDate: new Date(pubdateString).toLocaleDateString(), + guid: version, }; }) .get(), @@ -95,6 +100,7 @@ module.exports = async (ctx) => { description: content, link: `https://www.sketch.com/beta/`, pubDate: new Date(pubdateString).toLocaleDateString(), + guid: version, }; }) .get(), diff --git a/lib/routes/sketch/updates.js b/lib/routes/sketch/updates.js index 33b524799c..4f408dc0ef 100644 --- a/lib/routes/sketch/updates.js +++ b/lib/routes/sketch/updates.js @@ -9,7 +9,6 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); const list = $('div.update'); - ctx.state.data = { title: 'Sketch Release版本', link: response.url, @@ -35,20 +34,24 @@ module.exports = async (ctx) => { .attr('datetime') .substr(-4); const pubdateString = pubmonth + `-` + pubday + `-` + pubyear; - return { title: `${item .find('h2.update-version-title') .first() - .text()}`, + .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()}`, }; }) - .get(), }; }; diff --git a/lib/routes/universities/zju/list.js b/lib/routes/universities/zju/list.js new file mode 100644 index 0000000000..f8885522a3 --- /dev/null +++ b/lib/routes/universities/zju/list.js @@ -0,0 +1,87 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const url = require('url'); +const host = 'http://www.zju.edu.cn/'; +module.exports = async (ctx) => { + const type = ctx.params.type || 'xs'; + const link = host + type + `/list.htm`; + const response = await got({ + method: 'get', + url: link, + headers: { + Referer: host, + }, + }); + const $ = cheerio.load(response.data); + + function sortDate(e) { + // console.log(e); + const pubday = e.substr(-3, 2); + const pubmonth = e.substr(-6, 2); + const pubyear = e.substr(-11, 4); + const pubdateString = pubmonth + `-` + pubday + `-` + pubyear; + // console.log(pubdateString); + + return pubdateString; + } + function sortUrl(e) { + let linka = host; + if (e.search('redirect') !== -1) { + linka = link; + } else { + linka = e; + } + + return linka; + } + const list = $('#wp_news_w7 ul.news li') + .map(function() { + const info = { + title: $(this) + .find('a') + .text(), + link: sortUrl( + $(this) + .find('a') + .attr('href') + ), + date: sortDate($(this).text()), + }; + return info; + }) + .get(); + const out = await Promise.all( + list.map(async (info) => { + const title = info.title; + const date = info.date; + const itemUrl = url.resolve(host, info.link); + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const response = await got({ + method: 'get', + url: itemUrl, + headers: { + Referer: link, + }, + }); + const $ = cheerio.load(response.data); + const description = $('.right_content').html(); + const single = { + title: title, + link: itemUrl, + description: description, + pubDate: new Date(date).toLocaleDateString(), + }; + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: `浙江大学` + $('ul.submenu .selected').text(), + link: link, + item: out, + }; +};