爬爬爬爬爬爬

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)
}





猜你喜欢

转载自blog.csdn.net/weixin_44946147/article/details/119723941