package main import ( "fmt" "time" "encoding/json" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" domain "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain/v20180808" ) func HttpRequest(domName string) { credential := common.NewCredential( "AKIDwhCSRBeqlPnytiHZaKo31jCPL0PXP0JM", "nJYXEengIcfRxDCuMXR3PUHo43lBKDqa", ) cpf := profile.NewClientProfile() cpf.HttpProfile.Endpoint = "domain.tencentcloudapi.com" client, _ := domain.NewClient(credential, "", cpf) request := domain.NewCheckDomainRequest() request.DomainName = common.StringPtr(domName) response, err := client.CheckDomain(request) if _, ok := err.(*errors.TencentCloudSDKError); ok { fmt.Printf("\n %s An API error has returned: %s\n", domName ,err) return } if err != nil { panic(err) } //fmt.Printf("%s", response.ToJsonString()) // 定义空接口接收解析后的json数据 var unknown interface{} // 或:map[string]interface{} 结果是完全一样的 err = json.Unmarshal([]byte(response.ToJsonString()), &unknown) if err != nil { fmt.Println(domName, err) return } //fmt.Println(unknown) m := unknown.(map[string]interface{}) resp := m["Response"].(map[string]interface{}) canRegist := resp["Available"] //fmt.Println(domName, canRegist) canBool, _ := canRegist.(bool) if canBool { fmt.Printf("\n") fmt.Println(domName, canRegist) fmt.Printf("\n") } else { fmt.Printf("%s %d ",domName, canBool) } time.Sleep(10 * time.Millisecond) //fmt.Println(canBool, ok) //return canBool } func req_r(lay int, top string) { for h := 'a'; h<= 'z'; h++{ if lay==1 { str := fmt.Sprintf("%c.%s",h,top) //fmt.Printf("%s\n",str) HttpRequest(str) continue } for k := 'a'; k<= 'z'; k++{ if lay==2 { str := fmt.Sprintf("%c%c.%s",h,k,top) //fmt.Printf("%s\n",str) HttpRequest(str) continue } for i := 'a'; i <= 'z'; i++ { str := fmt.Sprintf("%c%c%c.%s",h,k,i,top) //fmt.Printf("%s\n",str) HttpRequest(str) } } } } func main() { HttpRequest("sdjfladf.com") req_r(2, "space") //for i := 1; i <= 3; i++ { //} //HttpRequest("frytea.com") }