style: auto format
This commit is contained in:
parent
09f9cb941c
commit
5f299e9270
|
|
@ -748,10 +748,13 @@ category 对应的关键词有
|
|||
</Route>
|
||||
|
||||
### 福建新闻
|
||||
|
||||
<Route author="jjlzg" example="/fjnews/fj/30" path="/fjnews/fznews"/>
|
||||
|
||||
### 福州新闻
|
||||
|
||||
<Route author="jjlzg" example="/fjnews/fz/30" path="/fjnews/fznews"/>
|
||||
|
||||
### 九江新闻
|
||||
|
||||
<Route author="jjlzg" example="/fjnews/jjnews" path="/fjnews/jjnews"/>
|
||||
|
|
|
|||
|
|
@ -3110,5 +3110,4 @@ router.get('/fjnews/fz/30', require('./routes/fjnews/fznews'));
|
|||
// 九江新闻jjnews
|
||||
router.get('/fjnews/jjnews', require('./routes/fjnews/jjnews'));
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -6,52 +6,50 @@ let host = 'http://news.fznews.com.cn/fzxw/';
|
|||
let citytitle = '福州新闻';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (ctx.params.city === 'fj') {
|
||||
host = 'http://news.fznews.com.cn/dsxw/';
|
||||
citytitle = '福建新闻';
|
||||
} else {
|
||||
host = 'http://news.fznews.com.cn/fzxw/';
|
||||
citytitle = '福州新闻';
|
||||
}
|
||||
if (ctx.params.city === 'fj') {
|
||||
host = 'http://news.fznews.com.cn/dsxw/';
|
||||
citytitle = '福建新闻';
|
||||
} else {
|
||||
host = 'http://news.fznews.com.cn/fzxw/';
|
||||
citytitle = '福州新闻';
|
||||
}
|
||||
|
||||
const response = await got.get(host);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.li-h32f14 li:not(.clearfix)').slice(0, ctx.params.limit).get();
|
||||
const out = await Promise.all(
|
||||
const response = await got.get(host);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.li-h32f14 li:not(.clearfix)').slice(0, ctx.params.limit).get();
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('a').text();
|
||||
const itemUrl = url.resolve(host, $('a').attr('href'));
|
||||
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('a').text();
|
||||
const itemUrl = url.resolve(host, $('a').attr('href'));
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const res = await got.get(itemUrl);
|
||||
const capture = cheerio.load(res.data);
|
||||
const contents = capture('.zhengwen').html();
|
||||
const time = capture('div.laiyuan div.left').text().substring(0, 19);
|
||||
const author = capture('.laiyuan').text().replace('分享到:', '');
|
||||
|
||||
const res = await got.get(itemUrl);
|
||||
const capture = cheerio.load(res.data);
|
||||
const contents = capture('.zhengwen').html();
|
||||
const time = capture('div.laiyuan div.left').text().substring(0, 19);
|
||||
const author = capture('.laiyuan').text().replace('分享到:', '');
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
author: author,
|
||||
description: contents,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
};
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
author: author,
|
||||
description: contents,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: citytitle,
|
||||
link: host,
|
||||
item: out,
|
||||
};
|
||||
ctx.state.data = {
|
||||
title: citytitle,
|
||||
link: host,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,41 +4,40 @@ const url = require('url');
|
|||
const host = 'http://tt.m.jxnews.com.cn/jjtop/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got.get(host);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('li.col-xs-12').get();
|
||||
const out = await Promise.all(
|
||||
const response = await got.get(host);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('li.col-xs-12').get();
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('.list-text-style').text();
|
||||
const itemUrl = url.resolve(host, $('a').attr('href'));
|
||||
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('.list-text-style').text();
|
||||
const itemUrl = url.resolve(host, $('a').attr('href'));
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const res = await got.get(itemUrl);
|
||||
const capture = cheerio.load(res.data);
|
||||
const contents = capture('content').html();
|
||||
const time = capture('div.col-xs-8').text().substring(0, 19);
|
||||
|
||||
const res = await got.get(itemUrl);
|
||||
const capture = cheerio.load(res.data);
|
||||
const contents = capture('content').html();
|
||||
const time = capture('div.col-xs-8').text().substring(0, 19);
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
description: contents,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
};
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
description : contents,
|
||||
pubDate : new Date(time).toUTCString(),
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title : '九江新闻',
|
||||
link : host,
|
||||
item : out,
|
||||
};
|
||||
ctx.state.data = {
|
||||
title: '九江新闻',
|
||||
link: host,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue