baidulogin

package module
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2020 License: GPL-3.0 Imports: 18 Imported by: 1

README

百度BDUSS获取工具 v1.2.1 Go语言

GoDoc

功能

增加 session 支持,数据安全性提高

百度: 获取百度帐号 BDUSS, PTOKEN, STOKEN 值

百度: 支持在线 手机/邮箱 安全验证(beta)

如何使用

Go语言程序, 可直接下载使用 点此查看发布页

在 (Linux, MacOS)终端/(Windows)命令提示符 中运行。

Windows 也可双击程序运行。

本程序会开启本地 http 服务器, 默认端口为9090.

程序运行前带入参数 "-h" 以查看帮助.

程序会列出一些本地服务器网址, 浏览器访问网址即可使用。

请注意,程序重启后请刷新一遍网页,因为程序重启会导致 session 清空,否则可能会出现错误。

如何手动编译安装

1. 安装Go语言运行环境

Linux:

export GOPATH=/path/to/your/gopath

Windows:

set GOPATH=C:\path\to\your\gopath

如果提示找不到 go 命令, 请先设置 PATH , 以Linux为例

export PATH=$PATH:$GOROOT/bin

$GOROOT 即Go语言的安装目录

2. 安装
编译安装(需要设置GOPATH环境变量)
go get -u -v github.com/Erope/Baidu-Login/cmd/Baidu-Login

编译生成的文件在GOPATH的bin目录下

如何将静态资源打包进程序

强烈建议使用 go.rice 将 http-files 目录内的文件打包进程序

详情: https://github.com/GeertJohan/go.rice

设置好环境变量 GOPATH:

export GOPATH=/path/to/your/gopath

将 $GOPATH/bin 加入 PATH 环境变量

export PATH=$PATH:$GOPATH/bin

安装 go.rice 相关依赖:

go get -u -v github.com/GeertJohan/go.rice
go get -u -v github.com/GeertJohan/go.rice/rice

将 $GOPATH/bin / %GOPATH%\bin 加入PATH环境变量, 最后执行以下命令编译程序:

rice embed-go
go build

Documentation

Index

Constants

View Source
const (
	// Version 版本号
	Version = "v1.2.1"
)

Variables

This section is empty.

Functions

func StartServer

func StartServer(port string)

StartServer 启动 http 服务

Types

type BaiduClient

type BaiduClient struct {
	*requester.HTTPClient
	// contains filtered or unexported fields
}

BaiduClient 记录登录百度所使用的信息

func NewBaiduClinet

func NewBaiduClinet() *BaiduClient

NewBaiduClinet 返回 BaiduClient 指针对象

func (*BaiduClient) BaiduLogin

func (bc *BaiduClient) BaiduLogin(username, password, verifycode, vcodestr string) (lj *LoginJSON)

BaiduLogin 发送 百度登录请求

func (*BaiduClient) SendCodeToUser

func (bc *BaiduClient) SendCodeToUser(verifyType, token string) (msg string)

SendCodeToUser 发送验证码到 手机/邮箱

func (*BaiduClient) VerifyCode

func (bc *BaiduClient) VerifyCode(verifyType, token, vcode, u string) (lj *LoginJSON)

VerifyCode 输入 手机/邮箱 收到的验证码, 验证登录

type LoginJSON

type LoginJSON struct {
	ErrInfo struct {
		No  string `json:"no"`
		Msg string `json:"msg"`
	} `json:"errInfo"`
	Data struct {
		CodeString   string `json:"codeString"`
		GotoURL      string `json:"gotoUrl"`
		Token        string `json:"token"`
		U            string `json:"u"`
		AuthSID      string `json:"authsid"`
		Phone        string `json:"phone"`
		Email        string `json:"email"`
		BDUSS        string `json:"bduss"`
		PToken       string `json:"ptoken"`
		SToken       string `json:"stoken"`
		CookieString string `json:"cookieString"`
	} `json:"data"`
}

LoginJSON 从百度服务器解析的数据结构

Directories

Path Synopsis
ecb
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL