forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1319 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
28 changed files
with
457 additions
and
124 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 was deleted.
Oops, something went wrong.
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,57 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id = '1', name = '重要通知' } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; | ||
|
||
const rootUrl = 'http://www.acpaa.cn'; | ||
const currentUrl = new URL(`article/taglist.jhtml?tagIds=${id}&tagname=${name}`, rootUrl).href; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const $ = cheerio.load(response); | ||
|
||
let items = $('div.text01 ul li a[title]') | ||
.slice(0, limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
return { | ||
title: item.prop('title'), | ||
link: new URL(item.prop('href'), rootUrl).href, | ||
pubDate: timezone(parseDate(item.find('span[title]').prop('title')), +8), | ||
}; | ||
}); | ||
|
||
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); | ||
|
||
item.title = content('div.xhjj_head01').text(); | ||
item.description = content('div.text01').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
const author = $('title').text().replace(/-/g, ''); | ||
const subtitle = $('span.myTitle').text().trim(); | ||
|
||
ctx.state.data = { | ||
item: items, | ||
title: `${author} - ${subtitle}`, | ||
link: currentUrl, | ||
description: $('meta[property="og:description"]').prop('content'), | ||
language: 'zh', | ||
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 = { | ||
'/:id?/:name?': ['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,19 @@ | ||
module.exports = { | ||
'acpaa.cn': { | ||
_name: '中华全国专利代理师协会', | ||
'.': [ | ||
{ | ||
title: '文章', | ||
docs: 'https://docs.rsshub.app/routes/other#zhong-hua-quan-guo-zhuan-li-dai-li-shi-xie-hui', | ||
source: ['/article/taglist.jhtml'], | ||
target: (url) => { | ||
url = new URL(url); | ||
const id = url.searchParams.get('id'); | ||
const name = url.searchParams.get('name'); | ||
|
||
return `/acpaa${id ? `/${id}${name ? `/${name}` : ''}` : ''}`; | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
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('/:id?/:name?', 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,44 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { art } = require('@/utils/render'); | ||
const { join } = require('path'); | ||
|
||
module.exports = async (ctx) => { | ||
const city = ctx.params.city === '全部' ? '' : ctx.params.city; | ||
const category = ctx.params.category === '全部' ? '' : ctx.params.category; | ||
const subcategory = ctx.params.subcategory === '全部' ? '' : ctx.params.subcategory; | ||
const keyword = ctx.params.keyword ? ctx.params.keyword : ''; | ||
|
||
const url = 'https://search.damai.cn/searchajax.html'; | ||
|
||
const response = await got(url, { | ||
searchParams: { | ||
keyword, | ||
cty: city, | ||
ctl: category, | ||
sctl: subcategory, | ||
tsg: 0, | ||
st: '', | ||
et: '', | ||
order: 3, | ||
pageSize: 30, | ||
currPage: 1, | ||
tn: '', | ||
}, | ||
}); | ||
const data = response.data; | ||
const list = data.pageData.resultData || []; | ||
|
||
ctx.state.data = { | ||
title: `大麦网票务 - ${city || '全国'} - ${category || '全部分类'}${subcategory ? ' - ' + subcategory : ''}${keyword ? ' - ' + keyword : ''}`, | ||
link: 'https://search.damai.cn/search.htm', | ||
item: list.map((item) => ({ | ||
title: item.nameNoHtml, | ||
author: item.actors ? cheerio.load(item.actors, null, false).text() : '大麦网', | ||
description: art(join(__dirname, 'templates/activity.art'), { | ||
item, | ||
}), | ||
link: `https://detail.damai.cn/item.htm?id=${item.projectid}`, | ||
})), | ||
}; | ||
}; |
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 = { | ||
'/activity/:city/:category/:subcategory/:keyword?': ['hoilc'], | ||
}; |
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,13 @@ | ||
module.exports = { | ||
'damai.cn': { | ||
_name: '大麦网', | ||
search: [ | ||
{ | ||
title: '票务更新', | ||
docs: 'https://docs.rsshub.app/routes/shopping#da-mai-wang', | ||
source: ['/search.html'], | ||
target: (_params, url) => `/damai/activity/全部/全部/全部/${new URL(url).searchParams.get('keyword') || ''}`, | ||
}, | ||
], | ||
}, | ||
}; |
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('/activity/:city/:category/:subcategory/:keyword?', require('./activity')); | ||
}; |
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,5 @@ | ||
<img src="{{ item.verticalPic }}"> | ||
<p>{{@ item.description }}</p> | ||
<p>地点:{{ item.venuecity }} | {{ item.venue }}</p> | ||
<p>时间:{{ item.showtime }}</p> | ||
<p>票价:{{ item.price_str }}</p> |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
'/blog/:language?': ['nczitzk'], | ||
'/blog/:language?/category/:category?': ['nczitzk'], | ||
}; |
Oops, something went wrong.