A python module for using Luogu Api. 一个用于洛谷API的的Python模块。
Github: https://github.com/hlwdy/pyluog
如何使用
首先,你需要使用`pip install pyluog`来安装本模块,然后再进行引用:
`python import pyluog `
User类型属性:
name 当前账号的用户名
password 当前账号的密码,如果通过非账号密码登录方式登录,则该属性值为’*’
sess 当前账号的session会话对象 (requests的Session类)
uid 当前账号的uid
你可以定义一个User类型的账号变量,需要两个字符串参数,分别是账号密码:
`python a=pyluog.User('name','password') `
注意,以上操作并没有进行登录,登录操作需要执行:
`python a.login() `
中途会要求输入验证码,请根据显示的图片验证码正确输入。
如果过程顺利,最后会输出 登录成功!。
除此之外,你还可以使用cookie进行登录 (两个参数,__client_id和你的uid):
`python a=pyluog.loginWithCookie('aaabbcc1233dd344ee','12345') `
这将返回一个登录过的User对象给变量a (cookie需要校验)。
登录操作完成后,你可以用:
a.getUserData() 获取当前用户的信息
a.getRecordList(‘name’,’1’) 获取指定用户的评测提交记录 (两个参数分别是用户名和页数)
- a.getNotification(1,1) 获取当前用户的通知,(两个参数分别是类型和页数)
类型1: @我的
类型2: 回复
类型3: 系统通知
a.QianDao() 执行签到
a.getLatestMessages() 获取私信最新消息列表
a.getMessagesRecord(‘uid’) 获取与指定用户的聊天记录 (注意参数是uid而不是用户名)
a.sendMessage(‘uid’,’content’) 向指定用户发送一条私信
a.getLastCode(‘P1001’) 获取你指定题目最后一次提交的代码
a.getMyPastes() 获取你发布的所有云剪贴板信息
以上操作均会返回一个json对象。
无需登录账号即可执行的操作:
pyluog.getUid(‘name’) 根据用户名获取该用户的uid,如果不存在则返回’-1’
- pyluog.searchProblem(‘keyword’,1,-1) 搜索题库内容 (三个参数分别是关键词,页数和题目难度,默认难度-1)
-1为全部难度
0为暂无评定
1为入门
2为普及-
3为普及/提高-
4为普及+/提高
5为提高+/省选-
6为省选/NOI-
7为NOI/NOI+/CTSC
pyluog.getContestList(‘1’) 获取比赛列表,参数为页数
pyluog.getProblemInfo(‘P1001’) 获取指定题目的详细内容 (包括题面,提交数,通过数,难度等)
Metadata
Release files for pyluog 0.13.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyluog-0.13.9.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyluog-0.13.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / pyluog-0.13.9.tar.gz
| Download URL | pyluog-0.13.9.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc03cdf3c4c8023281ba23fc654f6ddfe4664ffc683d9d2749b7d96356e9d92e
|
|
BLAKE2b-256 checksum How to use checksums |
9a9a4fa46b1034ed1c45b465f805f51f45f904bff808ac16a5e37ae33632befa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.7
|
Release files / pyluog-0.13.9-py3-none-any.whl
| Download URL | pyluog-0.13.9-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d85249a636f30bbfd09068c892dcbb0480d29b7518a82399c5d305ea1e8076b
|
|
BLAKE2b-256 checksum How to use checksums |
73d62c2ec472e3897291ed0cb8fa3c2c324e1c5cf9b6e7ecd3bb4a8d20c53ee7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.7
|