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 #4 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
23 changed files
with
397 additions
and
224 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 was deleted.
Oops, something went wrong.
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
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,46 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const timezone = require('@/utils/timezone'); | ||
|
||
module.exports = async (ctx) => { | ||
const link = 'https://www.suzhou.gov.cn/szxxgk/front/xxgk_right.jsp'; | ||
|
||
const { data: response } = await got(link); | ||
const $ = cheerio.load(response); | ||
const list = $('.tr_main_value_odd') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const title = item.find('a'); | ||
return { | ||
title: title.attr('title'), | ||
link: `https://www.suzhou.gov.cn${title.attr('href')}`, | ||
pubDate: timezone(parseDate(item.find('td:nth-child(3)').text().trim()), 8), | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = cheerio.load(response); | ||
|
||
item.description = $('.article-content').html(); | ||
item.author = $('dd.addWidth:nth-child(3) div').text().trim(); | ||
item.pubDate = $('meta[name="PubDate"]').length ? timezone(parseDate($('meta[name="PubDate"]').attr('content'), 'YYYY-MM-DD HH:mm:ss'), 8) : item.pubDate; | ||
item.category = $('.OwnerDept font') | ||
.toArray() | ||
.map((item) => $(item).text().trim()); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: '苏州市政府 - 政策公开文件', | ||
link, | ||
item: items, | ||
}; | ||
}; |
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,62 @@ | ||
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 { category = 'szfgw/ggl/nav_list' } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; | ||
|
||
const rootUrl = 'https://fg.suzhou.gov.cn'; | ||
const currentUrl = new URL(`${category}.shtml`, rootUrl).href; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const $ = cheerio.load(response); | ||
|
||
let items = $('h4 a[title]') | ||
.slice(0, limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
return { | ||
title: item.prop('title') || item.text(), | ||
link: new URL(item.prop('href'), rootUrl).href, | ||
author: item.find('.author').text(), | ||
pubDate: parseDate(item.parent().find('span.time').text().trim()), | ||
}; | ||
}); | ||
|
||
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('ucaptitle').text().trim(); | ||
item.description = content('ucapcontent').html(); | ||
item.author = content('span.ly b').text().trim(); | ||
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').prop('content')), +8); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
const author = $('meta[name="SiteName"]').prop('content'); | ||
const subtitle = $('meta[name="ColumnName"]').prop('content'); | ||
const image = new URL($('div.logo img').prop('src'), rootUrl).href; | ||
|
||
ctx.state.data = { | ||
item: items, | ||
title: `${author} - ${subtitle}`, | ||
link: currentUrl, | ||
description: $('meta[name="ColumnDescription"]').prop('content'), | ||
language: $('html').prop('lang'), | ||
image, | ||
subtitle, | ||
author, | ||
}; | ||
}; |
Oops, something went wrong.