自动领豆golang版
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动领豆golang版相关的知识,希望对你有一定的参考价值。
package main //51cto自动领豆 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() { //设置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() //构造登陆认证数据 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) //构造领豆数据 val_down := url.Values{} val_down.Set("do","getfreecredits") random_num := strconv.Itoa(rand.Float64()) val_down.Set("t",random_num) //领豆 res_my ,_ := client.PostForm("http://down.51cto.com/download.php",val_down) body1 ,_ := ioutil.ReadAll(res_my.Body) fmt.Println(string(body1)) //领取无忧币 client.Get("http://blog.51cto.com/appApi/sign/sign") }
本文出自 “高明” 博客,转载请与作者联系!
以上是关于自动领豆golang版的主要内容,如果未能解决你的问题,请参考以下文章
[Golang] kafka集群搭建和golang版生产者和消费者
天池中间件大赛Golang版Service Mesh思路分享