feat: 新增几家律师事务所官网文章 (#4872)

This commit is contained in:
snipersteve
2020-06-01 12:04:01 +08:00
committed by GitHub
parent 6df9f0a268
commit c47fd02bd1
9 changed files with 332 additions and 0 deletions

View File

@@ -338,6 +338,35 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="SettingDust" example="/uraaka-joshi/_rrwq" path="/uraaka-joshi/:id" :paramsDesc="['用户名']"/>
## 律师事务所文章
### 君合
<Route author="snipetsteve" example="/law/jh" path="/law/jh" />
### 通商
<Route author="snipetsteve" example="/law/ts" path="/law/ts" />
### 海问
<Route author="snipetsteve" example="/law/hw" path="/law/hw" />
### 环球
<Route author="snipetsteve" example="/law/hq" path="/law/hq" />
### 国枫
<Route author="snipetsteve" example="/law/gf" path="/law/gf" />
### 中伦
<Route author="snipetsteve" example="/law/zl" path="/law/zl" />
### 锦天城
<Route author="snipetsteve" example="/law/jtc" path="/law/jtc" />
## 马良行
### 产品更新

View File

@@ -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'));

41
lib/routes/law/gf.js Normal file
View File

@@ -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,
};
};

39
lib/routes/law/hq.js Normal file
View File

@@ -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,
};
};

39
lib/routes/law/hw.js Normal file
View File

@@ -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,
};
};

41
lib/routes/law/jh.js Normal file
View File

@@ -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,
};
};

41
lib/routes/law/jtc.js Normal file
View File

@@ -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,
};
};

41
lib/routes/law/ts.js Normal file
View File

@@ -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,
};
};

40
lib/routes/law/zl.js Normal file
View File

@@ -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,
};
};