This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
LuoGu
HoshinoTented edited this page Dec 30, 2018
·
9 revisions
LuoGu
是一个你谷的客户端类
它拥有以下构造器:
- constructor(val client : OkHttpClient = defaultClient)
接收一个OkHttpClient
对象, 用于进行 HTTP 请求
它拥有以下字段:
- homePage : String
返回一个你谷主页的 html 代码 - csrfToken : String
返回一个csrf-token
, 在很多地方都要用到这个 token - sliderPhotos : List<Pair<String, String>>
返回一个你谷主页的滚动图片列表, 其中
Pair.first
是 网址
Pair.second
是 图片链接 - practiceList : List<PracticeBlock>
返回一个试炼块
列表 - loggedUser : LoggedUser
返回一个当前客户端的LoggedUser
对象
即已经登录的用户
如果没有登录的用户, 则会抛出LuoGuException
它拥有以下方法:
- verifyCode(out : OutputStream) : Unit
将以当前客户端获取一个验证码, 并输出到out
- login(account : String, password : String, verifyCode : String) : LoggedUser
登录当前客户端
account
为账号
password
为密码
verifyCode
为验证码, 可以通过verifyCode(out : OutputStream) : Unit
得到
返回一个LoggedUser
, 即在本客户端登录的用户对象 - publicBenben(page : Int = 1) : List<LuoGuComment>
返回第 page 页的公开犇犇列表 - problemList(page : Int = 1, filter : ProblemSearchConfig = ProblemSearchConfig()) : List<Problem>
返回第 page 页, 符合 filter 条件的题目列表
以下是示例代码
/* import ... */
class Example {
public void example() {
LuoGu luogu = new LuoGu();
//获取验证码
luogu.verifyCode(new FileOutputStream(new File("...")));
System.out.print("Please input verify code: ");
String verifyCode = new Scanner(System.in).nextLine();
//登录
LoggedUser user = luogu.login("123456", "abcdef", "vrfc");
}
}
org.hoshino9.luogu
org.hoshino9.luogu.user
org.hoshino9.luogu.data
org.hoshino9.luogu.tag
org.hoshino9.luogu.benben
org.hoshino9.luogu.results
org.hoshino9.luogu.training
org.hoshino9.luogu.utils
org.hoshino9.luogu.photo
org.hoshino9.luogu.problem
org.hoshino9.luogu.problem.tags
org.hoshino9.luogu.paste
org.hoshino9.luogu.record
org.hoshino9.luogu.record.response
org.hoshino9.luogu.record.status
org.hoshino9.luogu.record.listener