forked from andeya/pholcus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_main.go
42 lines (34 loc) · 1.06 KB
/
example_main.go
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
package main
import (
"github.com/henrylee2cn/pholcus/config"
"github.com/henrylee2cn/pholcus/exec"
"github.com/henrylee2cn/pholcus/logs"
_ "github.com/pholcus/spider_lib" // 此为公开维护的spider规则库
// _ "github.com/my_lib" // 同样你也可以自由添加自己的规则库
)
func main() {
// 允许日志打印行号
logs.ShowLineNum()
// 初始化配置,不调用则为默认值
SetConf()
// 开始运行,参数:"web"/"gui"/"cmd",默认为web版
// 其中gui版仅支持Windows系统
exec.Run("web")
}
// 自定义相关配置,将覆盖默认值
func SetConf() {
//mongodb链接字符串
config.MGO.CONN_STR = "127.0.0.1:27017"
//mongodb数据库
config.MGO.DB = "pholcus"
//mongodb连接池容量
config.MGO.MAX_CONNS = 1024
//mysql服务器地址
config.MYSQL.CONN_STR = "root:@tcp(127.0.0.1:3306)"
//msyql数据库
config.MYSQL.DB = "pholcus"
//mysql连接池容量
config.MYSQL.MAX_CONNS = 1024
// Surfer-Phantom下载器配置
config.SURFER_PHANTOM.FULL_APP_NAME = "phantomjs" //phantomjs软件相对路径与名称
}