()
| 97 | } |
| 98 | |
| 99 | func main() { |
| 100 | |
| 101 | // POST data |
| 102 | post_arg := url.Values{ |
| 103 | "name": {"admin"}, |
| 104 | "pwd": {"admin"}, |
| 105 | } |
| 106 | |
| 107 | // http header |
| 108 | header := make(http.Header) |
| 109 | header.Set("Content-Type", "application/x-www-form-urlencoded") |
| 110 | |
| 111 | // Spider input: |
| 112 | // PageProcesser ; |
| 113 | // Task name used in Pipeline for record; |
| 114 | // AddUrlWithParams Params: |
| 115 | // 1. Url. |
| 116 | // 2. Responce type is "html" or "json" or "jsonp" or "text". |
| 117 | // 3. The urltag is name for marking url and distinguish different urls in PageProcesser and Pipeline. |
| 118 | // 4. The method is POST or GET. |
| 119 | // 5. The postdata is body string sent to sever. |
| 120 | // 6. The header is header for http request. |
| 121 | // 7. Cookies |
| 122 | // 8. Http redirect function |
| 123 | req := request.NewRequest("http://backadmin.hucong.net/main/user/login", "html", "site_login", "POST", post_arg.Encode(), header, nil, myRedirect) |
| 124 | |
| 125 | spider.NewSpider(NewMyPageProcesser(), "TaskName"). |
| 126 | AddRequest(req). |
| 127 | AddPipeline(pipeline.NewPipelineConsole()). // Print result on screen |
| 128 | SetThreadnum(3). // Crawl request by three Coroutines |
| 129 | Run() |
| 130 | } |
nothing calls this directly
no test coverage detected