Skip to content

Instantly share code, notes, and snippets.

@maple3142
Last active April 5, 2018 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maple3142/b8a1796c4e910e5399dc7f626663a884 to your computer and use it in GitHub Desktop.
Save maple3142/b8a1796c4e910e5399dc7f626663a884 to your computer and use it in GitHub Desktop.
(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(/&lt;/g,'<').replace(/&gt;/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