diff --git a/lib/router.js b/lib/router.js index 9b73d56ba..21cd382c2 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1448,9 +1448,6 @@ router.get('/uniqlo/stylingbook/:category?', lazyloadRouteHandler('./routes/uniq // unit-image router.get('/unit-image/films/:type?', lazyloadRouteHandler('./routes/unit-image/films')); -// digic-picture -router.get('/digic-pictures/:menu/:tags?', lazyloadRouteHandler('./routes/digic-pictures/index')); - // Xposed Module Repository router.get('/xposed/module/:mod', lazyloadRouteHandler('./routes/xposed/module')); @@ -1858,11 +1855,7 @@ router.get('/nwpu/:column', lazyloadRouteHandler('./routes/nwpu/index')); router.get('/us/supremecourt/argument_audio/:year?', lazyloadRouteHandler('./routes/us/supremecourt/argument_audio')); // 优设网 -router.get('/uisdc/talk/:sort?', lazyloadRouteHandler('./routes/uisdc/talk')); router.get('/uisdc/hangye/:caty?', lazyloadRouteHandler('./routes/uisdc/hangye')); -router.get('/uisdc/news', lazyloadRouteHandler('./routes/uisdc/news')); -router.get('/uisdc/zt/:title?', lazyloadRouteHandler('./routes/uisdc/zt')); -router.get('/uisdc/topic/:title?/:sort?', lazyloadRouteHandler('./routes/uisdc/topic')); // 美国中央情报局 router.get('/cia/foia-annual-report', lazyloadRouteHandler('./routes/us/cia/foia-annual-report')); diff --git a/lib/routes/digic-pictures/index.js b/lib/routes/digic-pictures/index.js deleted file mode 100755 index 6c5fcfe31..000000000 --- a/lib/routes/digic-pictures/index.js +++ /dev/null @@ -1,72 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const { menu, tags } = ctx.params; - const url = `https://digicpictures.com/${menu}/${tags}`; - const response = await got({ - method: 'get', - url, - }); - const data = response.data; - const $ = cheerio.load(data); - const list = $('ul#articles-slider li').get().slice(0, 5); - const articledata = await Promise.all( - list.map(async (item) => { - item = $(item); - const link = item.find('a').attr('href'); - const cache = await ctx.cache.get(link); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const response2 = await got({ - method: 'get', - url: link, - }); - - const articledata = response2.data; - const $2 = cheerio.load(articledata); - const title = $2('div#main-content>div>div>div').find('h1').text(); - const time = $2('div#main-content>div>div>div:nth-child(1) p').text(); - const images = $2('#main-slider img') - .get() - .map((item) => $2(item).attr('src')); - const content = $2('div#main-content>div>div>div:nth-child(2)') - .html() - .replace(//g, '') - .replace('', '
') - .replace(/<.?p>/g, ''); - const single = { - title, - link, - time, - content, - images, - }; - ctx.cache.set(link, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title: 'Digic Picture', - link: 'https://www.digicpictures.com/', - item: list.map((item, index) => { - let content = ''; - const imgstyle = `style="max-width: 650px; height: auto; object-fit: contain; flex: 0 0 auto;"`; - - content += `${articledata[index].time}
${articledata[index].content}
`; - if (articledata[index].images) { - for (let p = 0; p < articledata[index].images.length; p++) { - content += `
`; - } - } - return { - title: articledata[index].title, - description: content, - link: articledata[index].link, - pubDate: new Date(articledata[index].time), - }; - }), - }; -}; diff --git a/lib/routes/uisdc/news.js b/lib/routes/uisdc/news.js deleted file mode 100644 index 27f9795a5..000000000 --- a/lib/routes/uisdc/news.js +++ /dev/null @@ -1,34 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const rootUrl = 'https://www.uisdc.com/news'; - const response = await got({ - method: 'get', - url: rootUrl, - }); - - const $ = cheerio.load(response.data); - - $('.num').remove(); - - const items = $('.oneimg') - .map((_, item) => { - item = $(item); - const description = item.find('.item-content').html(); - const date = description.match(/[db|DB]-(\d{8})-\d{1}./)[1]; - return { - description, - link: rootUrl, - title: item.find('h3').text(), - pubDate: new Date(`${date.substr(0, 4)}-${date.substr(4, 2)}-${date.substr(6, 2)}`).toUTCString(), - }; - }) - .get(); - - ctx.state.data = { - title: $('title').text(), - link: rootUrl, - item: items, - }; -}; diff --git a/lib/routes/uisdc/talk.js b/lib/routes/uisdc/talk.js deleted file mode 100644 index 3c51d6597..000000000 --- a/lib/routes/uisdc/talk.js +++ /dev/null @@ -1,58 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const sort = ctx.params.sort || ''; - - const rootUrl = 'https://www.uisdc.com'; - const currentUrl = `${rootUrl}/talk${sort === '' ? '' : '?od=' + sort}`; - const response = await got({ - method: 'get', - url: currentUrl, - }); - - const $ = cheerio.load(response.data); - - const list = $('.content-title a') - .slice(0, 10) - .map((_, item) => { - item = $(item); - const time = item.parent().parent().prev().find('.time').text(); - return { - title: item.text(), - link: item.attr('href'), - author: item.find('.author-title h3 a').text(), - pubDate: new Date(time.indexOf('-') === 2 ? `${new Date().getFullYear()}-${time}` : time + ' GMT+8').toUTCString(), - }; - }) - .get(); - - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'post', - url: `${rootUrl}/ajax.php`, - form: { - action: 'get_comments', - pid: item.link.substr(item.link.length - 11, 6), - pd: '1', - }, - }); - - item.description = ''; - for (const p of detailResponse.data.data) { - item.description = `
${p.author}${p.city === '' ? '' : `(${p.city})`} 回复于 ${p.time}:

${p.content}

`; - } - - return item; - }) - ) - ); - - ctx.state.data = { - title: $('title').text(), - link: currentUrl, - item: items, - }; -}; diff --git a/lib/routes/uisdc/topic.js b/lib/routes/uisdc/topic.js deleted file mode 100644 index fb539e1e1..000000000 --- a/lib/routes/uisdc/topic.js +++ /dev/null @@ -1,55 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const date = require('@/utils/date'); - -module.exports = async (ctx) => { - const title = ctx.params.title || 'all'; - const sort = ctx.params.sort || ''; - - const rootUrl = 'https://www.uisdc.com'; - const currentUrl = `${rootUrl}/${title === 'all' ? 'hunter' : 'topic/' + title}${sort === '' ? '' : '?od=' + sort}`; - const response = await got({ - method: 'get', - url: currentUrl, - }); - - const $ = cheerio.load(response.data); - - const list = $('.item-left h2 a, .topic-item h2 a') - .slice(0, 10) - .map((_, item) => { - item = $(item); - return { - title: item.text(), - link: item.attr('href'), - }; - }) - .get(); - - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); - const content = cheerio.load(detailResponse.data); - - item.author = content('h3.author').text().replace(':', ''); - - content('.info .author').remove(); - - item.description = content('span.img-zoom').html() + content('.main .info').html(); - item.pubDate = date(detailResponse.data.match(/时间:(.*)<\/span>/)[1]); - - return item; - }) - ) - ); - - ctx.state.data = { - title: $('title').text(), - link: currentUrl, - item: items, - }; -}; diff --git a/lib/routes/uisdc/zt.js b/lib/routes/uisdc/zt.js deleted file mode 100644 index 919273419..000000000 --- a/lib/routes/uisdc/zt.js +++ /dev/null @@ -1,65 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const title = ctx.params.title || ''; - const rootUrl = 'https://www.uisdc.com'; - - let query, currentUrl; - - if (title === '' || title === 'hot') { - query = '.zt-item a h2'; - currentUrl = `${rootUrl}/zt?od=${title}`; - } else { - query = '.list-item-zt .item-content a h2'; - currentUrl = `${rootUrl}/zt/${title}`; - } - - const response = await got({ - method: 'get', - url: currentUrl, - }); - - const $ = cheerio.load(response.data); - - const list = $(query) - .slice(0, 10) - .map((_, item) => { - item = $(item); - return { - link: item.parent().attr('href'), - }; - }) - .get(); - - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); - const content = cheerio.load(detailResponse.data); - - if (title === '' || title === 'hot') { - item.title = content('.block-main h2').text(); - item.description = content('.block-main p').text(); - item.pubDate = new Date(content('.time').eq(0).text()).toUTCString(); - } else { - item.title = content('#post_title').text(); - item.description = content('.article').html(); - item.pubDate = new Date(content('.time').attr('title')).toUTCString(); - item.author = content('span.original_author, span.editor').text(); - } - - return item; - }) - ) - ); - - ctx.state.data = { - title: $('title').text(), - link: currentUrl, - item: items, - }; -}; diff --git a/lib/utils/request-wrapper.js b/lib/utils/request-wrapper.js index a2bb4e94a..7b7d9bf6b 100644 --- a/lib/utils/request-wrapper.js +++ b/lib/utils/request-wrapper.js @@ -86,6 +86,11 @@ const requestWrapper = ( options.headers['user-agent'] = config.ua; } + // Accept + if (!headersLowerCaseKeys.includes('Accept')) { + options.headers.Accept = '*/*'; + } + let urlHandler; try { urlHandler = new URL(options.url || url); diff --git a/lib/v2/zcool/discover.js b/lib/v2/zcool/discover.js index 4b8ac6fb7..17625d168 100644 --- a/lib/v2/zcool/discover.js +++ b/lib/v2/zcool/discover.js @@ -98,6 +98,9 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url: currentUrl, + headers: { + Referer: rootUrl, + }, }); const list = response.data.datas.map((item) => ({ diff --git a/website/docs/routes/design.mdx b/website/docs/routes/design.mdx index d72bd6672..04d42ecfc 100644 --- a/website/docs/routes/design.mdx +++ b/website/docs/routes/design.mdx @@ -40,12 +40,6 @@ | note | computer-skills | design-resources | design-software | design-tutorial | design\_information | -## Digic Picture {#digic-picture} - -### Works & News {#digic-picture-works-news} - - - ## Dribbble {#dribbble} ### Popular {#dribbble-popular} @@ -188,22 +182,6 @@ ## 优设网 {#you-she-wang} -### 设计专题 {#you-she-wang-she-ji-zhuan-ti} - - - 更多设计专题请参见 [优设专题](https://www.uisdc.com/zt) - - -### 细节猎人 {#you-she-wang-xi-jie-lie-ren} - - - 更多细节标签请参见 [全部标签](https://www.uisdc.com/alltopics) - - -### 设计话题 {#you-she-wang-she-ji-hua-ti} - - - ### 行业新闻 {#you-she-wang-hang-ye-xin-wen} @@ -212,10 +190,6 @@ | | events-activity | brand-news | new-products | -### 优设读报 {#you-she-wang-you-she-du-bao} - - - ## 站酷 {#zhan-ku} ### 发现(+ 推荐预设) {#zhan-ku-fa-xian-tui-jian-yu-she}