Skip to content

Instantly share code, notes, and snippets.

@maple3142
Created April 7, 2018 07:46
Show Gist options
  • Select an option

  • Save maple3142/5ad9a790c49d4711d5dea628ba39e2fb to your computer and use it in GitHub Desktop.

Select an option

Save maple3142/5ad9a790c49d4711d5dea628ba39e2fb to your computer and use it in GitHub Desktop.
(await Promise.all([1,2,3].map(x=>fetch(`https://tieba.baidu.com/p/5626879744?pn=${x}`).then(r=>r.text())))).filter((x,i)=>parseInt($(x).find('.tP')[0].textContent)===i+1).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()).join('\n\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment