baidu

package
v1.0.127 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTable = "baidu"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

NewClient 创建实例化

func (*Client) ConfigApiClientFun added in v1.0.126

func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun)

ConfigApiClientFun 日志配置

func (*Client) GetAk added in v1.0.126

func (c *Client) GetAk() string

func (*Client) GetLog added in v1.0.126

func (c *Client) GetLog() *golog.ApiClient

func (*Client) LocationIp added in v1.0.126

func (c *Client) LocationIp(ctx context.Context, ip string, notMustParams ...gorequest.Params) (*LocationIpResult, error)

LocationIp 普通IP定位 https://lbsyun.baidu.com/index.php?title=webapi/ip-api

func (*Client) Weather added in v1.0.126

func (c *Client) Weather(ctx context.Context, districtId string, notMustParams ...gorequest.Params) (*WeatherResult, error)

Weather 国内天气查询服务 https://lbsyun.baidu.com/index.php?title=webapi/weather

type ClientConfig added in v1.0.126

type ClientConfig struct {
	Ak string
}

ClientConfig 实例配置

type LocationIpResponse added in v1.0.126

type LocationIpResponse struct {
	Address string `json:"address"` // 详细地址信息
	Content struct {
		AddressDetail struct {
			Province     string `json:"province"` // 省份
			City         string `json:"city"`     // 城市
			District     string `json:"district"`
			Street       string `json:"street"`
			StreetNumber string `json:"street_number"`
			CityCode     int    `json:"city_code"` // 百度城市代码
			Adcode       string `json:"adcode"`
		} `json:"address_detail"`
		Address string `json:"address"` // 简要地址信息
		Point   struct {
			X string `json:"x"` // 当前城市中心点经度
			Y string `json:"y"` // 当前城市中心点纬度
		} `json:"point"`
	} `json:"content"`
	Status int `json:"status"`
}

type LocationIpResult added in v1.0.126

type LocationIpResult struct {
	Result LocationIpResponse // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

type WeatherResponse added in v1.0.126

type WeatherResponse struct {
	Status int `json:"status"`
	Result struct {
		Location struct {
			Country  string `json:"country"`
			Province string `json:"province"`
			City     string `json:"city"`
			Name     string `json:"name"`
			Id       string `json:"id"`
		} `json:"location"`
		Now struct {
			Text      string `json:"text"`
			Temp      int    `json:"temp"`
			FeelsLike int    `json:"feels_like"`
			Rh        int    `json:"rh"`
			WindClass string `json:"wind_class"`
			WindDir   string `json:"wind_dir"`
			Uptime    string `json:"uptime"`
		} `json:"now"`
		Forecasts []struct {
			TextDay   string `json:"text_day"`
			TextNight string `json:"text_night"`
			High      int    `json:"high"`
			Low       int    `json:"low"`
			WcDay     string `json:"wc_day"`
			WdDay     string `json:"wd_day"`
			WcNight   string `json:"wc_night"`
			WdNight   string `json:"wd_night"`
			Date      string `json:"date"`
			Week      string `json:"week"`
		} `json:"forecasts"`
	} `json:"result"`
	Message string `json:"message"`
}

type WeatherResult added in v1.0.126

type WeatherResult struct {
	Result WeatherResponse    // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL