您好,登錄后才能下訂單哦!
package main //51cto自動(dòng)領(lǐng)豆 import ( "github.com/crufter/goquery" "fmt" "math/rand" "net/http/cookiejar" "net/http" "net/url" "io/ioutil" "strconv" ) //用戶名和密碼 const ( NAME = "username" PWD = "password" ) func main() { //設(shè)置cookie cookieJar,_ := cookiejar.New(nil) client := &http.Client{ Jar:cookieJar, } //獲取CSRF隱藏字段 req , _ := http.NewRequest("GET","http://home.51cto.com/index",nil) req.Header.Set("User-Agent","'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1") req.Header.Set("Referer","http://home.51cto.com/index") req.Header.Set("Connection","[keep-alive]") res ,_ := client.Do(req) doc ,_ := goquery.Parse(res.Body) csrf := doc.Find("input").Val() //構(gòu)造登陸認(rèn)證數(shù)據(jù) val := url.Values{} val.Set("LoginForm[username]",NAME) val.Set("LoginForm[password]",PWD) val.Set("_csrf",csrf) val.Set("LoginForm[rememberMe]","0") //登陸獲取cookie client.PostForm("http://home.51cto.com/index",val) //構(gòu)造領(lǐng)豆數(shù)據(jù) val_down := url.Values{} val_down.Set("do","getfreecredits") random_num := strconv.Itoa(rand.Float64()) val_down.Set("t",random_num) //領(lǐng)豆 res_my ,_ := client.PostForm("http://down.51cto.com/download.php",val_down) body1 ,_ := ioutil.ReadAll(res_my.Body) fmt.Println(string(body1)) //領(lǐng)取無(wú)憂幣 client.Get("https://blog.51cto.com/appApi/sign/sign") }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。