|
@@ -20,20 +20,23 @@ import (
|
|
|
|
|
|
|
|
|
func AddSourceChangesVisitorsCovid() (err error) {
|
|
|
+ utils.FileLog.Info("爬取谷歌出行记录 开始爬取:")
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- fmt.Println("爬取谷歌出行记录失败 Err:" + err.Error())
|
|
|
- msg := "失败提醒"+"谷歌出行记录失败 ErrMsg:"+err.Error()
|
|
|
+ utils.FileLog.Info("爬取谷歌出行记录失败 Err:" + err.Error())
|
|
|
+ msg := "失败提醒"+"AddSourceChangesVisitorsCovid ErrMsg:"+err.Error()
|
|
|
go alarm_msg.SendAlarmMsg(msg, 3)
|
|
|
}
|
|
|
}()
|
|
|
-
|
|
|
fileName, err :=GetSourceChangesVisitorsCovid()
|
|
|
if err != nil {
|
|
|
err = errors.New("爬取谷歌出行记录失败"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ if fileName == "" {
|
|
|
+ err = errors.New("爬取谷歌出行记录失败, 文件下载失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
fs, err := os.Open(fileName)
|
|
|
if err != nil {
|
|
|
err = errors.New("打开文件失败"+err.Error())
|
|
@@ -149,7 +152,7 @@ func AddSourceChangesVisitorsCovid() (err error) {
|
|
|
err = errors.New("删除文件失败 "+ err.Error())
|
|
|
return
|
|
|
}
|
|
|
- println("入库成功")
|
|
|
+ utils.FileLog.Info("爬取谷歌出行记录 入库成功")
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -188,11 +191,11 @@ func GetSourceChangesVisitorsCovid() (filePathStr string, err error) {
|
|
|
if ev.TotalBytes != 0 {
|
|
|
completed = fmt.Sprintf("%0.2f%%", ev.ReceivedBytes/ev.TotalBytes*100.0)
|
|
|
}
|
|
|
- log.Printf("state: %s, completed: %s\n", ev.State.String(), completed)
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("爬取谷歌出行记录 state: %s, completed: %s\n", ev.State.String(), completed))
|
|
|
if ev.State == browser.DownloadProgressStateCompleted {
|
|
|
done <- ev.GUID
|
|
|
close(done)
|
|
|
- log.Print("download finished")
|
|
|
+ utils.FileLog.Info("爬取谷歌出行记录 download finished")
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -237,7 +240,7 @@ func GetSourceChangesVisitorsCovid() (filePathStr string, err error) {
|
|
|
// We can predict the exact file location and name here because of how we
|
|
|
// configured SetDownloadBehavior and WithDownloadPath
|
|
|
filePathStr = filepath.Join(dirPath, guid)
|
|
|
- log.Printf("wrote %s", filePathStr)
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("爬取谷歌出行记录 wrote %s", filePathStr))
|
|
|
return
|
|
|
}
|
|
|
|