const ( entry_login_url string ="xxxx " ) c:=&http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, } req,_:=http.NewRequest("GET",entry_login_url,nil) res,_:=c.Do(req) url1:=res.Header.Get("Location") req1,_:=http.NewRequest("POST",url1,nil) res1,_:=c.Do(req1) temp_cookies:=res1.Cookies() res1.Header.Set("Referer","xxxxxxl") elu,_:=c.Get(url1) doc,_:=goquery.NewDocumentFromReader(elu.Body) ltnode:=doc.Find(`[name="lt"]`) lt,_:=ltnode.Attr("value") excnode:=doc.Find(`[name="execution"]`) execution,_:=excnode.Attr("value") postValues :=url.Values{} //postValues.Add("service","http://entry.ccsu.cn") postValues.Add("username","xxxx") postValues.Add("password","xxxx") postValues.Add("lt",lt) postValues.Add("dllt","userNamePasswordLogin") postValues.Add("execution",execution) postValues.Add("_eventId","submit") postValues.Add("rmShown","1") postURL,_:=url.Parse(url1) Jar,_:=cookiejar.New(nil) Jar.SetCookies(postURL,temp_cookies) c.Jar=Jar res2,err:=c.PostForm(url1,postValues) fmt.Println(temp_cookies,res2,err) 如图 是我用 fiddler抓的数据 ![1.png](http://studygolang.qiniudn.com/170510/dba1ec0cdf9be535039786beb8d0b21b.png) ![2.png](http://studygolang.qiniudn.com/170510/636a6a6439891b085f5efb4ceca90272.png) ![3.png](http://studygolang.qiniudn.com/170510/e14e648c2a9218ca356514492ada8160.png) ![4.png](http://studygolang.qiniudn.com/170510/28ac2237992c19f3f3be6a0724bac0c8.png) 以上唯一没有post的数据是querystring中的那个地址 还有 cookie中的第一个cookie 因为我不知道如何设置 通过res1.cookie()只能获取一个 JSESSIONID_IDS1 而前面的不能获取 我也尝试过 手动加入第一个 (因为第一个是不变的,不知道那个网站后台是不是仅仅用一个作为标识)然后 jar.setcookie两次 也没有用 先不考虑重定向问题,只想看看post的数据哪里出毛病了 因为总是post不上 是不是上面的两个的问题 ,新手也不是非常懂 希望有能人来指点指点 实在是卡了太久