Explorar o código

获取隆众价格数据

rdluck %!s(int64=4) %!d(string=hai) anos
pai
achega
34ee426260
Modificáronse 2 ficheiros con 38 adicións e 1 borrados
  1. 37 0
      services/data_source_longzhong.go
  2. 1 1
      services/task.go

+ 37 - 0
services/data_source_longzhong.go

@@ -696,3 +696,40 @@ func GetLzProductPriceProduct() (err error) {
 	}
 	return
 }
+
+func GetLzProductPriceData() (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			fmt.Println("Err:" + err.Error())
+			go utils.SendEmail("获取隆众价格指标失败"+time.Now().Format("2006-01-02 15:04:05"), ";Err:"+err.Error(), utils.EmailSendToUsers)
+		}
+		if msg != "" {
+			fmt.Println("msg:", msg)
+			go utils.SendEmail("获取隆众价格指标失败"+time.Now().Format("2006-01-02 15:04:05"), ";msg:"+msg, utils.EmailSendToUsers)
+		}
+	}()
+
+	//chuchang, guonei, guoji, oil ,lingshou,guojioil,base,国内出厂,国内市场,国际市场,国内成品油批发价,国内成品油零售价,国际原油,基准价
+	typeMap := make(map[string]string)
+	//typeMap["chuchang"] = "国内出厂"
+	typeMap["guonei"] = "国内市场"
+	//typeMap["guoji"] = "国际市场"
+	//typeMap["oil"] = "国内成品油批发价"
+	//typeMap["lingshou"] = "国内成品油零售价"
+	//typeMap["guojioil"] = "国际原油"
+	//typeMap["base"] = "基准价"
+	username := "hzmd"
+	password := "HZMD2020"
+	for k, v := range typeMap {
+		fmt.Println(k, v)
+		getUrl := `https://openapi.oilchem.net/price/getPrice?password=` + password + `&type=` + k + `&username=` + username + `&inStartDate=2020-08-31&inEndDate=2020-09-02`
+		body, err := http.Get(getUrl)
+		fmt.Println("body")
+		fmt.Println(err)
+		fmt.Println(string(body))
+		fmt.Println("sleep:")
+		time.Sleep(31 * time.Second)
+	}
+	return
+}

+ 1 - 1
services/task.go

@@ -32,7 +32,7 @@ func Task123() {
 
 func Task() {
 	fmt.Println("start")
-	GetLzProductPriceProduct()
+	GetLzProductPriceData()
 	fmt.Println("end")
 }