Last active
April 5, 2018 05:57
-
-
Save maple3142/b8a1796c4e910e5399dc7f626663a884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(await Promise.all($('a').toArray().filter(x=>/^http.*\d{10}$/.test(x.textContent)).slice(1).map(r=>r.textContent.trim().replace('http:','https:')).map(x=>{ | |
return Promise.all([fetch(x).then(x=>x.text()),fetch(x+'?pn=2').then(x=>x.text())]) | |
}))).map(x=>{ | |
if($(x[0]).find('.l_pager').text())return x.join('') | |
else return x[0] | |
}).map(x=>$(x).find('.d_post_content').toArray().reduce((d,x)=>{ | |
const div=document.createElement('div') | |
div.innerHTML=x.innerHTML.replace(/<br>/g,'\n').replace(/</g,'<').replace(/>/g,'>') | |
if(div.textContent.replace(/(\n| )/g,'').length>=50&&!div.textContent.includes('广告')&&!div.textContent.includes('免费'))return d+'\n'+div.textContent | |
else return d | |
},'').trim()).reduce((d,x)=>{ | |
d.ct+=`第 ${d.id++} 章\n\n${x}\n\n\n` | |
return d | |
},{ct:'',id:1}).ct |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment