爬爬爬爬爬爬

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type T struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Miner                string  `json:"miner"`
		QualityPower         int64   `json:"qualityPower"`
		QualityPowerStr      string  `json:"qualityPowerStr"`
		QualityPowerPercent  float64 `json:"qualityPowerPercent"`
		RawPower             int64   `json:"rawPower"`
		RawPowerStr          string  `json:"rawPowerStr"`
		RawPowerPercent      float64 `json:"rawPowerPercent"`
		TotalQualityPower    float64 `json:"totalQualityPower"`
		TotalQualityPowerStr string  `json:"totalQualityPowerStr"`
		TotalRawPower        float64 `json:"totalRawPower"`
		TotalRawPowerStr     string  `json:"totalRawPowerStr"`
		Blocks               int     `json:"blocks"`
		WinCount             int     `json:"winCount"`
		BlockReward          float64 `json:"blockReward"`
		BlockRewardStr       string  `json:"blockRewardStr"`
		Owner                string  `json:"owner"`
		Worker               string  `json:"worker"`
		Tag                  string  `json:"tag"`
		IsVerified           int     `json:"isVerified"`
		PeerId               string  `json:"peerId"`
		PowerRank            int     `json:"powerRank"`
		Sectors              struct {
			SectorSize    int64  `json:"sectorSize"`
			SectorSizeStr string `json:"sectorSizeStr"`
			SectorCount   int    `json:"sectorCount"`
			ActiveCount   int    `json:"activeCount"`
			FaultCount    int    `json:"faultCount"`
			RecoveryCount int    `json:"recoveryCount"`
		} `json:"sectors"`
		Balance struct {
			Balance          float64 `json:"balance"`
			BalanceStr       string  `json:"balanceStr"`
			Available        float64 `json:"available"`
			AvailableStr     string  `json:"availableStr"`
			SectorsPledge    float64 `json:"sectorsPledge"`
			SectorsPledgeStr string  `json:"sectorsPledgeStr"`
			LockedFunds      float64 `json:"lockedFunds"`
			LockedFundsStr   string  `json:"lockedFundsStr"`
			FeeDebtStr       string  `json:"feeDebtStr"`
		} `json:"balance"`
		Local struct {
			Ip       string `json:"ip"`
			Location string `json:"location"`
		} `json:"local"`
	} `json:"data"`
}
const webhook_url = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

func dingToInfo(s string) bool {
	content, data := make(map[string]string), make(map[string]interface{})
	content["content"] = s
	data["msgtype"] = "text"
	data["text"] = content
	b, _ := json.Marshal(data)

	resp, err := http.Post(webhook_url,
		"application/json",
		bytes.NewBuffer(b))
	if err != nil {
		fmt.Println(err)
	}
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
	return true
}

func GetBianCheng() string {
	url := "https://api.filscout.com/api/v1/miners/f07830/info"

	r,_:= http.NewRequest("POST",url,nil)
	resposen,err := http.DefaultClient.Do(r)
	if err != nil {
		fmt.Println("error: ",err)
		return ""
	}
	defer resposen.Body.Close()
	r1,_ := ioutil.ReadAll(resposen.Body)
	//fmt.Println(string(r1))
	return string(r1)
}


func main() {

	result := GetBianCheng()
	fmt.Println(result)
	var config T
	if err := json.Unmarshal([]byte(result), &config); err == nil {
	}
	fmt.Println(config.Data.Sectors.FaultCount)
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值