-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'DIYgod:master' into master
- Loading branch information
Showing
37 changed files
with
3,700 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const iconv = require('iconv-lite'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { category = 'xxkd' } = ctx.params; | ||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30; | ||
|
||
const rootUrl = 'http://www.auto-stats.org.cn'; | ||
const currentUrl = new URL(`${category}.asp`, rootUrl).href; | ||
|
||
const { data: response } = await got(currentUrl, { | ||
responseType: 'buffer', | ||
}); | ||
|
||
const $ = cheerio.load(iconv.decode(response, 'gbk')); | ||
|
||
let items = $('a.dnews font') | ||
.slice(0, limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
const title = item.text(); | ||
const pubDate = title.match(/(\d{4}(?:\/\d{1,2}){2}\s\d{1,2}(?::\d{2}){2})/)?.[1] ?? undefined; | ||
|
||
return { | ||
title: title.replace(/●/, '').split(/(\d+/)[0], | ||
link: new URL(item.parent().prop('href'), rootUrl).href, | ||
pubDate: timezone(parseDate(pubDate, 'YYYY/M/D H:mm:ss'), +8), | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: detailResponse } = await got(item.link, { | ||
responseType: 'buffer', | ||
}); | ||
|
||
const content = cheerio.load(iconv.decode(detailResponse, 'gbk')); | ||
|
||
item.description = content('table tbody tr td.dd').last().html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
const subtitle = $('title').text().split(/——/).pop(); | ||
const image = new URL('images/logo.jpg', rootUrl).href; | ||
|
||
ctx.state.data = { | ||
item: items, | ||
title: $('title').text(), | ||
link: currentUrl, | ||
description: subtitle, | ||
language: 'zh', | ||
image, | ||
subtitle, | ||
allowEmpty: true, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/:category?': ['nczitzk'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module.exports = { | ||
'auto-stats.org.cn': { | ||
_name: '中国汽车工业协会统计信息网', | ||
'.': [ | ||
{ | ||
title: '分类', | ||
docs: 'https://docs.rsshub.app/routes/other#zhong-guo-qi-che-xie-hui-tong-ji-xin-xi-wang-fen-lei', | ||
source: ['/:category'], | ||
target: (params) => { | ||
const category = params.category; | ||
|
||
return `/auto-stats${category ? `/${category.replace(/\.asp$/, '')}` : ''}`; | ||
}, | ||
}, | ||
{ | ||
title: '信息快递', | ||
docs: 'https://docs.rsshub.app/routes/other#zhong-guo-qi-che-xie-hui-tong-ji-xin-xi-wang-fen-lei', | ||
source: ['/xxkd.asp'], | ||
target: '/auto-stats/xxkd', | ||
}, | ||
{ | ||
title: '工作动态', | ||
docs: 'https://docs.rsshub.app/routes/other#zhong-guo-qi-che-xie-hui-tong-ji-xin-xi-wang-fen-lei', | ||
source: ['/gzdt.asp'], | ||
target: '/auto-stats/gzdt', | ||
}, | ||
{ | ||
title: '专题分析', | ||
docs: 'https://docs.rsshub.app/routes/other#zhong-guo-qi-che-xie-hui-tong-ji-xin-xi-wang-fen-lei', | ||
source: ['/ztfx.asp'], | ||
target: '/auto-stats/ztfx', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/:category?', require('./')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { category = '1' } = ctx.params; | ||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30; | ||
|
||
const rootUrl = 'http://www.caam.org.cn'; | ||
const currentUrl = new URL(`chn/1/cate_${category}/list_1.html`, rootUrl).href; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const $ = cheerio.load(response); | ||
|
||
let items = $('span.cont') | ||
.slice(0, limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
const a = item.parent(); | ||
|
||
return { | ||
title: item.text(), | ||
link: new URL(a.prop('href'), currentUrl).href, | ||
pubDate: parseDate(a.find('span.time').text(), '[YYYY.MM.DD]'), | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: detailResponse } = await got(item.link); | ||
|
||
const content = cheerio.load(detailResponse); | ||
|
||
const infoEls = content('div.fourTop em'); | ||
|
||
item.title = content('div.fourTop h2').text(); | ||
item.description = content('div.fourBox').html(); | ||
item.author = infoEls.length <= 1 ? undefined : content('div.fourTop em').last().text(); | ||
item.pubDate = parseDate(infoEls.first().text()); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
const author = $('div.footer a').first().text(); | ||
const subtitle = $('div.topMeuns ul li a').last().text(); | ||
const image = new URL('images/header-back-7.png', rootUrl).href; | ||
|
||
ctx.state.data = { | ||
item: items, | ||
title: `${author} - ${subtitle}`, | ||
link: currentUrl, | ||
description: $('meta[property="og:description"]').prop('content'), | ||
language: $('html').prop('lang'), | ||
image, | ||
subtitle, | ||
author, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/:category?': ['nczitzk'], | ||
}; |
Oops, something went wrong.