@@ -510,6 +510,18 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<Route author="loveely7" example="/oschina/topic/weekly-news" path="/oschina/topic/:topic" :paramsDesc="['主题名, 可从[全部主题](https://www.oschina.net/question/topics)进入主题页, 在 URL 中找到']"/>
|
||||
|
||||
## 拉勾网
|
||||
|
||||
::: tip 提示
|
||||
|
||||
拉勾网官方提供职位的[邮件订阅](https://www.lagou.com/s/subscribe.html),请根据自身需要选择使用。
|
||||
|
||||
:::
|
||||
|
||||
### 职位招聘
|
||||
|
||||
<Route author="hoilc" example="/lagou/jobs/JavaScript/上海" path="/lagou/jobs/:position/:city" :paramsDesc="['职位名,可以参考[拉勾网首页](https://www.lagou.com)的职位列表', '城市名,请参考[拉勾网支持的全部城市](https://www.lagou.com/jobs/allCity.html)']"/>
|
||||
|
||||
## 洛谷
|
||||
|
||||
### 日报
|
||||
|
||||
@@ -2321,6 +2321,9 @@ router.get('/blogs/hedwig/:type', require('./routes/blogs/hedwig'));
|
||||
// LoveHeaven
|
||||
router.get('/loveheaven/update/:slug', require('./routes/loveheaven/update'));
|
||||
|
||||
// 拉勾
|
||||
router.get('/lagou/jobs/:position/:city', require('./routes/lagou/jobs'));
|
||||
|
||||
// 扬州大学
|
||||
router.get('/yzu/home/:type', require('./routes/universities/yzu/home'));
|
||||
router.get('/yzu/yjszs/:type', require('./routes/universities/yzu/yjszs'));
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
async function getCookie(url, ctx) {
|
||||
const cache_key = `lagou-cookie-${new Date().toLocaleDateString()}`;
|
||||
const cached_cookie = await ctx.cache.get(cache_key);
|
||||
if (cached_cookie) {
|
||||
return cached_cookie;
|
||||
}
|
||||
const { headers } = await got.get(url, { headers: { Referer: 'https://www.lagou.com/' } });
|
||||
const cookie = headers['set-cookie']
|
||||
.filter((c) => c.match(/(user_trace_token|X_HTTP_TOKEN)/))
|
||||
.map((c) => c.split(';')[0])
|
||||
.join('; ');
|
||||
ctx.cache.set(cache_key, cookie);
|
||||
return cookie;
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const city = ctx.params.city;
|
||||
const position = ctx.params.position;
|
||||
|
||||
const url = `https://www.lagou.com/jobs/list_${encodeURIComponent(position)}?px=new&city=${encodeURIComponent(city)}`;
|
||||
|
||||
const cookie = await getCookie(url, ctx);
|
||||
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: `https://www.lagou.com/jobs/positionAjax.json?px=new&city=${encodeURIComponent(city)}&needAddtionalResult=false`,
|
||||
headers: {
|
||||
Referer: url,
|
||||
Cookie: cookie,
|
||||
},
|
||||
form: {
|
||||
first: true,
|
||||
pn: 1,
|
||||
kd: position,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.data.success) {
|
||||
throw response.data.msg;
|
||||
}
|
||||
|
||||
const list = response.data.content.positionResult.result;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${position} - ${city} - 拉勾网`,
|
||||
link: url,
|
||||
item: list.map((item) => ({
|
||||
title: `${item.positionName}[${city === '全国' ? item.city + '·' : ''}${item.businessZones ? item.businessZones[0] : item.district}] - ${item.companyShortName}`,
|
||||
author: item.companyShortName,
|
||||
description: `薪资:${item.salary}<br>要求:${item.workYear} / ${item.education}<br>公司名称:${item.companyFullName}<br>公司描述:${item.industryField} / ${item.financeStage} / ${item.companySize}${
|
||||
item.companyLabelList && item.companyLabelList.length !== 0 ? '<br>公司标签:' + item.companyLabelList.join(', ') : ''
|
||||
}<br>职位优势:${item.positionAdvantage}${item.positionLables ? '<br>职位标签:' + item.positionLables.join(', ') : ''}${item.linestaion ? '<br>附近线路:' + item.linestaion : ''}`,
|
||||
link: `https://www.lagou.com/jobs/${item.positionId}.html`,
|
||||
pubDate: new Date(item.createTime),
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user