Skip to content

Instantly share code, notes, and snippets.

@shionryuu
Created April 22, 2015 11:23
Show Gist options
  • Save shionryuu/84bfbd76b048d84edb08 to your computer and use it in GitHub Desktop.
Save shionryuu/84bfbd76b048d84edb08 to your computer and use it in GitHub Desktop.
ants-go 测试
package main
import (
"encoding/json"
"fmt"
"github.com/wcong/ants-go/ants/action/http"
"io"
"io/ioutil"
Http "net/http"
"net/url"
)
func main() {
client := Http.DefaultClient
resp, err := client.PostForm("http://127.0.0.1:8200/crawl", url.Values{"spider": {"dump_test_spider"}})
if err != nil {
fmt.Println(err.Error())
return
}
defer resp.Body.Close()
startResult := http.StartSpiderResult{}
body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err = json.Unmarshal(body, &startResult); err != nil {
fmt.Println(err.Error())
return
}
fmt.Printf("%v\n", startResult)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment