-
Notifications
You must be signed in to change notification settings - Fork 0
/
readurl.js
116 lines (101 loc) · 2.11 KB
/
readurl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const
fs=require ("fs"),
xlsx=require ("xlsx")
cheerio = require('cheerio'),
request = require('superagent');
class Handle{
excle(){
let
i,
x,
url,
urlArr=[],
realm,
know='know.baidu.com',
wenda='zhidao.baidu.com',
ask='ask.360kad.com',
wukong='www.wukong.com',
sogou='wenwen.sogou.com',
iask='iask.sina.com.cn',
kuaiwen='kuaiwen.pcbaby.com.cn',
tieba='tieba.baidu.com',
realmReg=/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/,
rangeReg=/[0-9]+$/g,
workbook=xlsx.readFile('file.xlsx'),
sheetName=workbook.SheetNames,
sheet1=workbook.Sheets[sheetName[0]],
arr=xlsx.utils.sheet_to_json(sheet1,{header:1}),
ws=xlsx.utils.aoa_to_sheet(arr),
ref=sheet1['!ref'],
range=ref.match(rangeReg)[0];
for(i=2;i<range;i++){
url=ws['E'+i].v,
realm=url.match(realmReg)[0],
console.log(realm)
let
readknow=()=>{
request.get(url)
.end((err,res)=>{
console.log(res)
})
},
// 手百问答
readwenda=()=>{
},
// 360问答
readask=()=>{
},
// 康爱多
readwukong=()=>{
},
// 悟空问答
readsogou=()=>{
},
// 搜狗问答
readiask=()=>{
console.log('新浪')
},
// 新浪问答
kuaiwen=()=>{
},
// 快问
tieba=()=>{
};
// 百度贴吧
switch(realm){
case know:
readknow();
break;
case wenda:
readwenda();
break;
case ask:
readask();
break;
case wukong:
readwukong();
break;
case sogou:
readsogou();
break;
case iask:
readiask();
break;
case kuaiwen:
readkuaiwen();
break;
case tieba:
readtieba();
break;
default:
x="Looking forward to the Weekend";
}
console.log(x)
};
}
read(){
}
}
var a=new Handle()
a.excle()
a.read()