format
This commit is contained in:
parent
0e847d2233
commit
e51d8f0d98
|
|
@ -18,12 +18,14 @@ module.exports = async (ctx) => {
|
|||
author: $el.find('.userInfo .l').text(),
|
||||
content: $el.find('.reply_content .message').html(),
|
||||
date: $el
|
||||
.children()
|
||||
.first()
|
||||
.find('small')
|
||||
.children()
|
||||
.remove()
|
||||
.end().text().slice(3),
|
||||
.children()
|
||||
.first()
|
||||
.find('small')
|
||||
.children()
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.slice(3),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
|
|
|
|||
|
|
@ -19,14 +19,17 @@ module.exports = async (subjectID, minLength) => {
|
|||
rate = $rateEl.attr('class').match(/sstars(\d)/)[1];
|
||||
}
|
||||
|
||||
let dateString = $el.find('small.grey').text().slice(2);
|
||||
const dateString = $el
|
||||
.find('small.grey')
|
||||
.text()
|
||||
.slice(2);
|
||||
let date;
|
||||
if(dateString.includes('ago')) {
|
||||
if (dateString.includes('ago')) {
|
||||
// 处理表示相对日期的字符串
|
||||
const list = dateString
|
||||
.match(/(\dd )?(\d{1,2}h )?(\d{1,2}m )?ago/)
|
||||
.slice(1)
|
||||
.map(s => s ? Number(s.slice(0, -2)) : 0);
|
||||
.match(/(\dd )?(\d{1,2}h )?(\d{1,2}m )?ago/)
|
||||
.slice(1)
|
||||
.map((s) => (s ? Number(s.slice(0, -2)) : 0));
|
||||
|
||||
date = DateTime.local().minus({
|
||||
days: list[0],
|
||||
|
|
|
|||
|
|
@ -34,25 +34,37 @@ module.exports = async (ctx) => {
|
|||
|
||||
const $scriptEls = $content.find('script');
|
||||
const info = [
|
||||
$($scriptEls[0]).html().match(/,"(.+)"/)[1],
|
||||
$($scriptEls[1]).html().match(/"(.+)"/)[1] + ', ',
|
||||
$($scriptEls[2]).html().match(/"(.+)"/)[1],
|
||||
$($scriptEls[3]).html().match(/"(.+)"/)[1],
|
||||
$($scriptEls[0])
|
||||
.html()
|
||||
.match(/,"(.+)"/)[1],
|
||||
$($scriptEls[1])
|
||||
.html()
|
||||
.match(/"(.+)"/)[1] + ', ',
|
||||
$($scriptEls[2])
|
||||
.html()
|
||||
.match(/"(.+)"/)[1],
|
||||
$($scriptEls[3])
|
||||
.html()
|
||||
.match(/"(.+)"/)[1],
|
||||
];
|
||||
|
||||
const text = info.reduce(
|
||||
(text, field) => text.replace(/<script>[\s\S]+?<\/script>/, field),
|
||||
$content.children().not('center').parent().html()
|
||||
$content
|
||||
.children()
|
||||
.not('center')
|
||||
.parent()
|
||||
.html()
|
||||
);
|
||||
$container.prepend(`<p>${text}</p>`);
|
||||
|
||||
const dateString = $1('.detail_main_right_conbg_tit')
|
||||
.children()
|
||||
.last()
|
||||
.text()
|
||||
.trim()
|
||||
.substring(5);
|
||||
console.log($container.html());
|
||||
.children()
|
||||
.last()
|
||||
.text()
|
||||
.trim()
|
||||
.substring(5);
|
||||
console.log($container.html());
|
||||
|
||||
return {
|
||||
title: $el.find('a').text(),
|
||||
|
|
|
|||
|
|
@ -4532,6 +4532,10 @@ lru-cache@4.1.3, lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2:
|
|||
pseudomap "^1.0.2"
|
||||
yallist "^2.1.2"
|
||||
|
||||
luxon@^1.3.3:
|
||||
version "1.3.3"
|
||||
resolved "https://registry.yarnpkg.com/luxon/-/luxon-1.3.3.tgz#e66e8537a62c9b351ba69b766d7fb70b07ab5e57"
|
||||
|
||||
macaddress@^0.2.8:
|
||||
version "0.2.8"
|
||||
resolved "https://registry.npmjs.org/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12"
|
||||
|
|
|
|||
Loading…
Reference in New Issue