mpspider
1.0.0
Crawl the historical articles of the official account, parse them into markdown files, generate gitbook projects, and finally generate kindle books.
PS :
book.json Supports two crawling methods:
PS : Summary article refers to the article page of a public account, such as the article "The Road to Architects"
Steps 1~6 are fully automatic, 7 depends on your own situation
npm i mpspider -g # 第一种方式
mpspider article https://mp.weixin.qq.com/s/CIPosICgva9haqstMDIHag -d dest_path
# 第二种方式,需要手动配置代理,点击公众号「查看历史文章」,详见下面介绍,支持手机微信和 pc 微信列表
mpspider proxy -d dest_path -p proxy_port After crawling, a gitbook project will be created in dest_path
Execute the command
# 进入抓取后gitbook的地址
cd dest_path
# 创建readme.md,gitbook不创建会报错
touch README.md
# 有必要可以创建book.json,参考gitbook文档
gitbook serve
# 访问地址查看效果
# -------
# 生成电子书
gitbook mobi ./ name.mobi
Reference: http://anyproxy.io/cn/#%E8%AF%81%E4%B9%A6%E9%85%8D%E7%BD%AE
anyproxy --rule lib/anyproxyRule.jsmpspider.config.jsSupported configuration items:
Array.sort writing method, and it is passed into item object, with options such as mid , title , content , release , uri , etc. release is the pinyin file name, and the default sorting is based on releasefilter : an article content filter function, filters the article list array items through items.filter(option.filter) . The item content includes: mid , title , contentlistFilter : List article filtering, only used in proxy mode, filter data according to the json object of the article list, the commonly used object fields areauthor , title , copyright_stat , content_url , source_url , digest , content , cover , is_multi , etc.datetime publish timestampturndown : supports four options: keep , remove , rule , and plugins , corresponding to the four configuration items of turndown respectivelyafterConverter : turndown After converting html to markdown content, pass the content string into the function. After processing, return the processed stringExample:
const turndownPluginGfm = require ( 'turndown-plugin-gfm' ) ;
module . exports = {
filter : item => {
if ( item . title . indexOf ( '广告' ) !== - 1 ) {
return false ;
}
return true ;
} ,
turndown : {
keep : 'span' ,
remove : 'span' ,
rule : {
strikethrough : {
filter : [ 'del' , 's' , 'strike' ] ,
replacement : function ( content ) {
return '~' + content + '~' ;
}
}
} ,
plugins : [ turndownPluginGfm . gfm , turndownPluginGfm . tables ]
} ,
afterConverter : content => {
return content . replace ( / <(.+?)> / g , ( i , m ) => {
return `< ${ m } >` ;
} ) ;
}
} ; After git clone source code, enter the folder and execute npm i
commander and ora for command processingsummary.md to replace the content of the inner link brew install caskroom/cask/calibrenpm i gitbook-cli -g 


