MCPcopy
hub / github.com/hu17889/go_spider / main

Function main

example/github_login_profile_page_processor/main.go:99–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97}
98
99func 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}

Callers

nothing calls this directly

Calls 5

RunMethod · 0.80
SetThreadnumMethod · 0.80
AddPipelineMethod · 0.80
AddRequestMethod · 0.80
NewMyPageProcesserFunction · 0.70

Tested by

no test coverage detected