```shell
go get -u github.com/zhshch2002/goreq
```
```go
package main
import (
"fmt"
"github.com/zhshch2002/goreq"
)
func main() {
h, err := goreq.Get("https://httpbin.org/").Do().HTML()
if err != nil {
panic(err)
}
fmt.Println(h.Find("title").Text())
}
```
支持的链式配置:
* `AddParam(k, v string)`
* `AddParams(v map[string]string)`
* `AddHeader(key, value string)`
* `AddHeaders(v map[string]string)`
* `AddCookie(c *http.Cookie)`
* `SetUA(ua string)`
* `SetBasicAuth(username, password string)`
* `SetProxy(urladdr string)`
* Set request body data
* `SetBody(b io.Reader)` basic setting
* `SetRawBody(b []byte)`
* `SetFormBody(v map[string]string)`
* `SetJsonBody(v interface{})`
* `SetMultipartBody(data ...interface{})` Set a slice of`FormField` and`FormFile` struct as body data
* `Callback(fn func(resp *Response)` Set a callback func run after req`Do()`
Goreq 支持线程安全,自动处理编码,以及中间件。具体请见[README](https://github.com/zhshch2002/goreq)
有疑问加站长微信联系(非本文作者)