Skip to content

Commit

Permalink
Removed login
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed Jun 22, 2016
1 parent 2b06019 commit 2b9f3f8
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,9 @@ func getCookie(cookieFileName string, silence bool) (cookieJar *cookiejar.Jar, h
}
}
if needLogin && !silence {
var username, password string
bufferedReader := bufio.NewReader(os.Stdin)
fmt.Print("Enter your Baidu ID: ")
usernameByte, _, _ := bufferedReader.ReadLine()
username = string(usernameByte)
if username == "" {
return nil, true
}
fmt.Print("Enter your Baidu Password: ")
fmt.Scan(&password)
if password == "" {
return nil, true
}
result, loginErr := BaiduLogin(username, password, cookieJar)
if loginErr == nil && result > 0 {
fmt.Println("Successfully login")
cookieStr := ""
for _, cookie := range GetCookies(cookieJar) {
cookieStr += cookie.Name + "=" + cookie.Value + "\n"
}
ioutil.WriteFile("cookie.txt", []byte(cookieStr), 0644)

fmt.Println("Your cookie has been written into cookie.txt")
} else {
fmt.Println("Error while login:")
fmt.Println(loginErr)
time.Sleep(5e9)
return nil, true
}
fmt.Println("Cannot login, since baidu has switched to RSA login, and I have no time to make a new login program. You have to make a cookie.txt, and paste your cookie in the file.")
fmt.Println("Cookie Format: BDUSS=xxxxxxx")
return nil, true
} else if needLogin && silence {
return nil, true
}
Expand Down

0 comments on commit 2b9f3f8

Please sign in to comment.