Last active
November 24, 2015 17:46
-
-
Save Luavis/6d4691c1c4a28cab99a8 to your computer and use it in GitHub Desktop.
facebook autopoker for korean with golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"container/list" | |
"flag" | |
"fmt" | |
"github.com/headzoo/surf" | |
"os" | |
"path" | |
"time" | |
) | |
func main() { | |
var ( | |
email string | |
passwd string | |
) | |
flag.StringVar(&email, "m", "", "Your facebook email") | |
flag.StringVar(&passwd, "p", "", "Your facebook passwd") | |
flag.Parse() | |
if len(email) == 0 || len(passwd) == 0 { | |
fmt.Fprintf(os.Stderr, "Error: Please fill your email or paswd\n\n") | |
fmt.Fprintf(os.Stderr, "Usage of %s:\n", path.Base(os.Args[0])) | |
flag.PrintDefaults() | |
return | |
} | |
poke_url := "https://m.facebook.com/pokes" | |
browser := surf.NewBrowser() | |
err := browser.Open(poke_url) | |
if err != nil { | |
panic(err) | |
} else { | |
login_form := browser.Forms()[1] | |
login_form.Input("email", email) | |
login_form.Input("pass", passwd) | |
login_form.Submit() | |
for { | |
err := browser.Open(poke_url) | |
if err != nil { | |
time.Sleep(time.Minute) | |
} | |
var poke_links list.List | |
for _, s := range browser.Links() { | |
if s.Text == "나도 콕 찔러보기" { | |
poke_links.PushBack(s.Url().String()) | |
} | |
} | |
for e := poke_links.Front(); e != nil; e = e.Next() { | |
browser.Open(e.Value.(string)) // poke!! | |
println("poke!") | |
} | |
time.Sleep(time.Minute) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment