func HasWrongUserJson(userName string) (bool, error) { var parameters simple_http.Parameters parameters.Add("un", misc.UrlQueryEscape(misc.ToGBK(userName))) resp, err := simple_http.Get("http://tieba.baidu.com/i/sys/user_json", parameters, nil) if err != nil { return false, err } var x struct { RawName string `json:"raw_name"` } err2 := json.Unmarshal(resp, &x) if err2 != nil { return false, err2 } return x.RawName == "", nil }
func GetUid(userName string) (uint64, error) { //忠于百度的写法,用Get取 var parameters simple_http.Parameters parameters.Add("un", misc.UrlQueryEscape(misc.ToGBK(userName))) resp, err := simple_http.Get("http://tieba.baidu.com/i/sys/user_json", parameters, nil) //println(string(resp)) if err != nil { return 0, err } var x struct { Creator struct { ID uint64 `json:"id"` } `json:"creator"` } err2 := json.Unmarshal(resp, &x) if err2 != nil { return 0, err2 } return x.Creator.ID, nil }