1 Star 0 Fork 0

Azlan/go-jandan

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jandan.go 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
azlan 提交于 2017-06-18 13:14 . change name
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/adyzng/jandan/core"
log "gopkg.in/clog.v1"
)
var (
saveDir = flag.String("destination", "pic", "destination folder to save the picture")
maxPages = flag.Int("max", 0, "the max pages to crawl")
startPage = flag.Int("page", 1, "start page to crawl")
)
func init() {
if err := log.New(log.CONSOLE, log.ConsoleConfig{
Level: log.INFO,
BufferSize: 100,
}); err != nil {
fmt.Printf("Fail to create new console logger, error %+v.\n", err)
os.Exit(1)
}
if err := log.New(log.FILE, log.FileConfig{
Level: log.TRACE,
Filename: "log\\jandan.log",
BufferSize: 100,
}); err != nil {
fmt.Printf("Failed to create file logger, error %+v.\n", err)
os.Exit(1)
}
}
func main() {
flag.Parse()
log.Info("Crawl start")
defer log.Shutdown()
dest := *saveDir
if abs := filepath.IsAbs(dest); !abs {
dest, _ = filepath.Abs(dest)
}
// make destination folder if not exists
if err := os.MkdirAll(dest, os.ModePerm); err != nil && !os.IsExist(err) {
log.Fatal(2, "Failed to create destination folder %+v.", *saveDir)
}
log.Info("Destination %s, StartPage: %d, MaxPages: %d.", dest, *startPage, *maxPages)
jd := core.NewJanDan(core.Config{
Destination: dest,
StartPage: int32(*startPage),
MaxPages: int32(*maxPages),
BaseURL: "http://jandan.net",
})
jd.Run()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xxaz/go-jandan.git
git@gitee.com:xxaz/go-jandan.git
xxaz
go-jandan
go-jandan
master

搜索帮助