From c47fd02bd189c28bf93f1796570ec966addd9e89 Mon Sep 17 00:00:00 2001 From: snipersteve Date: Mon, 1 Jun 2020 12:04:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=87=A0=E5=AE=B6?= =?UTF-8?q?=E5=BE=8B=E5=B8=88=E4=BA=8B=E5=8A=A1=E6=89=80=E5=AE=98=E7=BD=91?= =?UTF-8?q?=E6=96=87=E7=AB=A0=20(#4872)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/other.md | 29 +++++++++++++++++++++++++++++ lib/router.js | 21 +++++++++++++++++++++ lib/routes/law/gf.js | 41 +++++++++++++++++++++++++++++++++++++++++ lib/routes/law/hq.js | 39 +++++++++++++++++++++++++++++++++++++++ lib/routes/law/hw.js | 39 +++++++++++++++++++++++++++++++++++++++ lib/routes/law/jh.js | 41 +++++++++++++++++++++++++++++++++++++++++ lib/routes/law/jtc.js | 41 +++++++++++++++++++++++++++++++++++++++++ lib/routes/law/ts.js | 41 +++++++++++++++++++++++++++++++++++++++++ lib/routes/law/zl.js | 40 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 332 insertions(+) create mode 100644 lib/routes/law/gf.js create mode 100644 lib/routes/law/hq.js create mode 100644 lib/routes/law/hw.js create mode 100644 lib/routes/law/jh.js create mode 100644 lib/routes/law/jtc.js create mode 100644 lib/routes/law/ts.js create mode 100644 lib/routes/law/zl.js diff --git a/docs/other.md b/docs/other.md index 726cd6087..67b3e072d 100644 --- a/docs/other.md +++ b/docs/other.md @@ -338,6 +338,35 @@ type 为 all 时,category 参数不支持 cost 和 free +## 律师事务所文章 + +### 君合 + + + +### 通商 + + + +### 海问 + + + +### 环球 + + + +### 国枫 + + + +### 中伦 + + + +### 锦天城 + + ## 马良行 ### 产品更新 diff --git a/lib/router.js b/lib/router.js index f8348f7ad..289ad79bd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2771,6 +2771,27 @@ router.get('/zhutix/latest', require('./routes/zhutix/latest')); // arXiv router.get('/arxiv/:query', require('./routes/arxiv/query')); +// 环球律师事务所文章 +router.get('/law/hq', require('./routes/law/hq')); + +// 海问律师事务所文章 +router.get('/law/hw', require('./routes/law/hw')); + +// 国枫律师事务所文章 +router.get('/law/gf', require('./routes/law/gf')); + +// 通商律师事务所文章 +router.get('/law/ts', require('./routes/law/ts')); + +// 锦天城律师事务所文章 +router.get('/law/jtc', require('./routes/law/jtc')); + +// 中伦律师事务所文章 +router.get('/law/zl', require('./routes/law/zl')); + +// 君合律师事务所文章 +router.get('/law/jh', require('./routes/law/jh')); + // Mobilism router.get('/mobilism/release', require('./routes/mobilism/release')); diff --git a/lib/routes/law/gf.js b/lib/routes/law/gf.js new file mode 100644 index 000000000..1d59950d9 --- /dev/null +++ b/lib/routes/law/gf.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.grandwaylaw.com/cn/publications/articles.html'; + const ori_url = 'http://www.grandwaylaw.com'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('.cbw ul li').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const title = $('a').html(); + const sub_url = $('a').attr('href'); + const itemUrl = ori_url + sub_url; + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title, + link: itemUrl, + description: $d('.xwzz .txt').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +}; diff --git a/lib/routes/law/hq.js b/lib/routes/law/hq.js new file mode 100644 index 000000000..008075b3a --- /dev/null +++ b/lib/routes/law/hq.js @@ -0,0 +1,39 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.glo.com.cn/news/publications_list13.html'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('ul.ul-list li').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const title = $('a').attr('title'); + const itemUrl = $('a').attr('href'); + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title, + link: itemUrl, + description: $d('article').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +}; diff --git a/lib/routes/law/hw.js b/lib/routes/law/hw.js new file mode 100644 index 000000000..c3296ef2f --- /dev/null +++ b/lib/routes/law/hw.js @@ -0,0 +1,39 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.haiwen-law.com/class/view?id=19'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('div.newlist ul li.clearfix').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const title = $('.ittitle a').html(); + const itemUrl = $('.ittitle a').attr('href'); + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title, + link: itemUrl, + description: $d('.large').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +}; diff --git a/lib/routes/law/jh.js b/lib/routes/law/jh.js new file mode 100644 index 000000000..9627a6cd2 --- /dev/null +++ b/lib/routes/law/jh.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.junhe.com/legal-updates'; + const ori_url = 'http://www.junhe.com'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('.news-content ul.list').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const title = $('h1').html(); + const sub_url = $('a').attr('href'); + const itemUrl = ori_url + sub_url; + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title, + link: itemUrl, + description: $d('.d-content').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +}; diff --git a/lib/routes/law/jtc.js b/lib/routes/law/jtc.js new file mode 100644 index 000000000..52533c6fc --- /dev/null +++ b/lib/routes/law/jtc.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://www.allbrightlaw.com/CN/10475.aspx'; + const ori_url = 'https://www.allbrightlaw.com'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('.news_list_img ul li').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const title = $('.news_txt h2').html(); + const sub_url = $('a').attr('href'); + const itemUrl = ori_url + sub_url; + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title, + link: itemUrl, + description: $d('.news_content_box .news_content').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +}; diff --git a/lib/routes/law/ts.js b/lib/routes/law/ts.js new file mode 100644 index 000000000..cb3fa3234 --- /dev/null +++ b/lib/routes/law/ts.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.tongshang.com/researches'; + const ori_url = 'http://www.tongshang.com'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('.tableList .newsTab').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const title = $('a').html(); + const sub_url = $('a').attr('href'); + const itemUrl = ori_url + sub_url; + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title, + link: itemUrl, + description: $d('.col-md-9').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +}; diff --git a/lib/routes/law/zl.js b/lib/routes/law/zl.js new file mode 100644 index 000000000..47a7db790 --- /dev/null +++ b/lib/routes/law/zl.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.zhonglun.com/zx/zlgd.html'; + const ori_url = 'http://www.zhonglun.com'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + const list = $('.zx_list ul li').get(); + + const out = await Promise.all( + list.map(async (item) => { + const $ = cheerio.load(item); + const sub_url = $('a').attr('href'); + const itemUrl = ori_url + sub_url; + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const responses = await got.get(itemUrl); + const $d = cheerio.load(responses.data); + + const single = { + title: $d('.news_main .txt span').html(), + link: itemUrl, + description: $d('.news_main').html(), + }; + + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + ctx.state.data = { + title: $('title').text(), + link: url, + item: out, + }; +};