Requests-GoGo 的 HTTP 请求库
Requests-Go,一个类似于 Python Requests 的 Go 语言 HTTP 请求库。
安装
go get github.com/solos/requests
用法
package main import r "github.com/solos/requests" import "fmt" func main() { kwargs := r.M{} options := r.M{ "timeout": 10, } cookies := map[string]string{ "user": "solos", } headers := map[string]string{ "content-Type": "application/json", } data := map[string]string{ "hello": "world", } req := &r.Request{Args: kwargs} resp, _ := req.MakeRequest("GET", "http://www.example.com", r.Timeout(10), r.Headers(headers), r.Cookies(cookies), r.Options(options), r.Data(data)) fmt.Println(resp.Content) }
评论