Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe8b51e

Browse filesBrowse files
committed
编译数据
1 parent 3317120 commit fe8b51e
Copy full SHA for fe8b51e

4 files changed

+143-48Lines changed: 143 additions & 48 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎build/compile.js‎

Copy file name to clipboardExpand all lines: build/compile.js
+26-26Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -114,36 +114,36 @@ function copy(src, dst) {
114114
}
115115

116116

117-
// 监听实时编译
118-
watch.watchTree(path.join(path.dirname(__dirname),'/'), function (f, curr, prev) {
119-
if (typeof f == "object" && prev === null && curr === null) {
120-
console.log(success(" → :watching ") + '/template/');
121-
// Finished walking the tree
122-
} else if (prev === null) {
123-
124-
// f is a new file
125-
} else if (curr.nlink === 0) {
126-
// f was removed
127-
} else {
117+
// // 监听实时编译
118+
// watch.watchTree(path.join(path.dirname(__dirname),'/'), function (f, curr, prev) {
119+
// if (typeof f == "object" && prev === null && curr === null) {
120+
// console.log(success(" → :watching ") + '/template/');
121+
// // Finished walking the tree
122+
// } else if (prev === null) {
123+
124+
// // f is a new file
125+
// } else if (curr.nlink === 0) {
126+
// // f was removed
127+
// } else {
128128

129-
if(/\.styl$/.test(f)){
130-
CreateStyl('/template/styl/index.styl','/.deploy/css/index.css')
131-
}else if(/\.js$/.test(f)){
129+
// if(/\.styl$/.test(f)){
130+
// CreateStyl('/template/styl/index.styl','/.deploy/css/index.css')
131+
// }else if(/\.js$/.test(f)){
132132

133-
CreateJS('/template/js/index.js','/.deploy/js/index.js')
133+
// CreateJS('/template/js/index.js','/.deploy/js/index.js')
134134

135-
}else if(/\.ejs$/.test(f)){
136-
// 首页生成
137-
ReadTmpToHTML('/template/index.ejs','/.deploy/index.html');
138-
ReadTmpToHTML('/template/list.ejs','/.deploy/list.html');
135+
// }else if(/\.ejs$/.test(f)){
136+
// // 首页生成
137+
// ReadTmpToHTML('/template/index.ejs','/.deploy/index.html');
138+
// ReadTmpToHTML('/template/list.ejs','/.deploy/list.html');
139139

140-
}else if(/\.md$/.test(f)){
141-
var mdp = f.replace(path_root,'');
142-
var dep = path.join('/.deploy/',mdp);
143-
ReadTmpToHTML('/template/details.ejs',dep.replace('.md','.html'),mdp);
144-
}
145-
}
146-
})
140+
// }else if(/\.md$/.test(f)){
141+
// var mdp = f.replace(path_root,'');
142+
// var dep = path.join('/.deploy/',mdp);
143+
// ReadTmpToHTML('/template/details.ejs',dep.replace('.md','.html'),mdp);
144+
// }
145+
// }
146+
// })
147147

148148

149149
function CreateJS(from_path,to_path){
Collapse file

‎build/crawler.js‎

Copy file name to clipboardExpand all lines: build/crawler.js
+113-18Lines changed: 113 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,124 @@ var request = require('superagent');
22
var cheerio = require('cheerio');
33
var toMarkdown = require('to-markdown');
44
var path = require('path');
5+
var process = require('process');
56
var fs = require('fs');
6-
7+
var color = require('colors-cli/safe');
8+
var error = color.red.bold;
9+
var warn = color.yellow;
10+
var notice = color.blue;
11+
var success = color.green;
712

813
var param = process.argv.slice(2);
914

10-
var from_path = param[0];
11-
var to_path = param[1];
1215

13-
if(!from_path) return console.error("请输入请求参数!");
14-
if(!to_path) return console.error("请输入写入目标目录!");
16+
// 需要爬的命令
17+
// var arr = ["find"];
18+
// var arr = [];
19+
var arr = [];
20+
// var arr = ["arch","axel","chsh","comm","compress","csplit","cut","dd","dig","dmesg","domainname","du","enable","fdisk","file","ftp","htpasswd","id","insmod","losetup","ls","lynx","mail","mkinitrd","netstat","nslookup","od","passwd","pgrep","ping","quota","restorecon","rmmod","screen","sed","semanage","smbclient","split","startx","sudo","tee","tftp","wall","wget","which","accept","apt-get","apt-key","apt-sortpkgs","aptitude","awk","clockdiff","cupsenable","dnf","dpkg-reconfigure","dpkg","expr","gcc","gdb","ldconfig","ldd","lpadmin","make","ngrep","nm","ntpdate","objdump","perl","php","protoize","pssh","pstack","readelf","reject","rsync","speedtest-cli","tempfile","test","vdfuse","xargs"];
21+
22+
// 还没有爬到的命令:--> ["bye","uucico","uucp","uupick","uuto","git","gitview","mattrib","mc","mcopy","mdel","mdir","mmove","mread","mren","mshowfat","mtoolstest","rhmask","tmpwatch","lndir","mcd","mdeltree","mdu","mlabel","mmd","mmount","mrd","mzip","rmt","cfdisk","ext2ed","fsck.ext2","fsck.minix","fsconf","mbadblocks","mformat","mkdosfs","mkfs.ext2","mkfs.minix","mkfs.msdos","mpartition","sfdisk","symlinks","apmd","aumix","eval","fbset","kbdconfig","liloconfig","minfo","mkkickstart","modinfo","mouseconfig","rdate","setconsole","setenv","setup","sndconfig","SVGAText Mode","timeconfig","adduser","fwhois","gitps","newgrp","procinfo","rwho","sliplogin","suspend","swatch","userconf","vlock","whois","mtype","rgrep","dip","getty","mingetty","ppp-off","smbd(samba daemon)","uulog","uustat","uux","dnsconf","efax","httpd","minicom","netconf","netconfig","pppstats","samba","setserial","shapecfg(shaper configuration)","smbd(samba daemon)","statserial(status ofserial port)","testparm(test parameter)","tty(teletypewriter)","uuname","wall(write all)","ytalk","smbclient(samba client)","pppsetup","dumpkeys","loadkeys","MAKEDEV","rdev","setleds","archive","ctlinnd","getlist","inncheck","mailconf","messages","metamail","mutt","nntpget","pine","slrn","X WINDOWS SYSTEM","reconfig","startx(start X Window)","Xconfigurator","XF86Setup" ,"nc/netcat","locate/slocate","get_module"]
23+
// 已经存在的命令:----> []
24+
// 名字不对的命令:----> ["ar","locate","slocate","clock","resize","cu","nc"]
25+
// 网站中没有的命令
26+
var empty_command = [];
27+
// 已经爬过/存在的命令
28+
var exists_command = [];
29+
// 名字不对的命令
30+
var name_command = [];
31+
var arr_len = 0;
32+
33+
arr[arr_len]&&CreatMarkdownQuery(arr[arr_len]);
34+
35+
36+
function CreatMarkdownQuery(query){
37+
var url = 'http://man.linuxde.net/'+query;
38+
var new_to_path = path.join(path.dirname(__dirname),'command/'+query+'.md')
39+
40+
41+
if(!arr[arr_len]){
42+
console.log('还没有爬到的命令:-->', JSON.stringify(empty_command) )
43+
console.log('已经存在的命令:---->', JSON.stringify(exists_command) )
44+
console.log('名字不对的命令:---->', JSON.stringify(name_command) )
45+
return;
46+
};
47+
48+
++arr_len;
49+
50+
// 文件已经存在
51+
if(exists( new_to_path )) {
52+
exists_command.push(query)
53+
CreatMarkdownQuery(arr[arr_len]);
54+
return console.log(" → error:文件存在 ",new_to_path)
55+
}
56+
57+
request.get(url).end(function(err, res){
58+
59+
if(arr[arr_len]){
60+
CreatMarkdownQuery(arr[arr_len]);
61+
}
62+
// console.log("res.text:::--->",res.text)
63+
64+
if(//.test(res.text)){
65+
empty_command.push(query)
66+
return console.log(" → error: 没有爬到数据,命令" + query +'不存在!')
67+
}
68+
var $ = cheerio.load(res.text);
69+
var description = $('title').text();
70+
description = description.replace(/(.*)/,'')
71+
72+
var title = $('.main h1.l');
73+
title = title.text();
74+
title = title.replace(/$/,'');
75+
76+
77+
if(query!==title){
78+
name_command.push(query)
79+
return console.log(" → error: 名字不对的命令 ",query)
80+
}
81+
82+
if(!title){
83+
empty_command.push(query);
84+
return console.log(error(" → error: 命令" + query +'不存在!标题为空'))
85+
}
86+
var content = $('#content-index').remove()
87+
content = $('.main .post_bd').html();
88+
var md_str = toMarkdown(content);
89+
90+
md_str = md_str.replace(/linuxde.net/g,'jsdig.com');
91+
md_str = md_str.replace(/linuxde/g,'jsdigname');
92+
md_str = md_str.replace(/\*\*(.*?)\*\*/g,' **$1** ');
93+
md_str = md_str.replace(/^\s\*\*(.*?)\*\*/g,'**$1**');
94+
md_str = title + '\n===\n'+description+'\n\n## 补充说明\n\n' + md_str;
95+
md_str = md_str.replace(/<pre>/gi,'```\n')
96+
md_str = md_str.replace(/<\/pre>/gi,'\n```')
97+
md_str = md_str.replace(/<span.*?>/gi,'')
98+
md_str = md_str.replace(/<\/span>/gi,'')
99+
md_str = md_str.replace(/\[[^\]]*\]\(.*?\)/g,function(str){
100+
str.replace(/\[(.*?)\]/,'');
101+
return RegExp.$1;
102+
})
103+
// console.log("md_str--->",md_str)
104+
md_str += '\n\n\n<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->'
105+
106+
fs.writeFileSync(new_to_path, md_str ,'utf-8');
107+
console.log(success(" → OK!"),new_to_path)
108+
});
109+
}
110+
111+
112+
113+
/**
114+
* 指定URL爬
115+
*/
116+
15117

16-
CreatMarkdown(from_path,to_path)
118+
// var from_path = param[0];
119+
// var to_path = param[1];
120+
// if(!from_path) return console.error("请输入请求参数!");
121+
// if(!to_path) return console.error("请输入写入目标目录!");
122+
// CreatMarkdown(from_path,to_path)
17123

18124
function CreatMarkdown(from_path,to_path){
19125

@@ -25,18 +131,7 @@ function CreatMarkdown(from_path,to_path){
25131

26132
request.get(from_path).end(function(err, res){
27133
// console.log("to_path::",to_path)
28-
var md_str = res.text
29-
30-
md_str = md_str.replace(/<pre>/gi,'```\n')
31-
md_str = md_str.replace(/<\/pre>/gi,'\n```')
32-
md_str = md_str.replace(/<span.*?>/gi,'')
33-
md_str = md_str.replace(/<\/span>/gi,'')
34-
md_str = md_str.replace(/\[[^\]]*\]\(.*?\)/g,function(str){
35-
str.replace(/\[(.*?)\]/,'');
36-
return RegExp.$1;
37-
})
38-
39-
fs.writeFileSync(to_path, toMarkdown(md_str).toString() ,'utf-8');
134+
fs.writeFileSync(to_path, toMarkdown(res.text).toString() ,'utf-8');
40135
console.log(" → ",to_path)
41136
});
42137

Collapse file

‎command/scp.md‎

Copy file name to clipboardExpand all lines: command/scp.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scp
22
===
3-
3+
44
加密的方式在本地主机和远程主机之间复制文件
55

66
## 补充说明
@@ -33,8 +33,8 @@ scp(选项)(参数)
3333

3434
### 参数
3535

36-
* 源文件:指定要复制的源文件。
37-
* 目标文件:目标文件。格式为`user@host:filename`(文件名为目标文件的名称)。
36+
* 源文件:指定要复制的源文件。
37+
* 目标文件:目标文件。格式为`user@host:filename`(文件名为目标文件的名称)。
3838

3939
### 实例
4040

Collapse file

‎dist/data.json‎

Copy file name to clipboardExpand all lines: dist/data.json
+1-1Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.