- package main
-
- import (
- "fmt"
- "github.com/astaxie/beego/httplib"
- "net/http"
- "net/url"
- "time"
- )
-
- func main() {
- content := "提交内容"
- req := httplib.Post("https://www.baidu.com").SetProxy(func(request *http.Request) (*url.URL, error) {
- u := new(url.URL)
- u.Scheme = "http" // 代理协议
- u.Host = "127.0.0.1:49389" // 代理IP 及端口
- return u, nil
- })
- req.SetTimeout(500*time.Millisecond, 500*time.Microsecond) //设置超时时间
- req.Body(content)
- result, _ := req.String()
- fmt.Println(result)
- }