Download any ebook from Z-Library with a single sentence.
Tech stack: Z-Library eapi search + Playwright headless bypasses Cloudflare for downloads
No Telegram bot needed, no extra API key needed, only a Z-Library account.
Usage (say to me)
- "Help me download 《Atomic Habits》"
- "Download 三体 epub"
- "Download Designing Data-Intensive Applications"
Commands
python3 skills/zbook/scripts/zbook.py "书名或作者"
python3 skills/zbook/scripts/zbook.py --format epub --lang en "Atomic Habits"
python3 skills/zbook/scripts/zbook.py --lang zh "三体 刘慈欣"
python3 skills/zbook/scripts/zbook.py --index 1 "深度工作" # 选第2个结果
python3 skills/zbook/scripts/zbook.py --json "Atomic Habits" # JSON 输出
python3 skills/zbook/scripts/zbook.py --setup # 首次配置
Configuration
Config file:~/.zbook/config.json
{
"email": "your@email.com",
"password": "your_password",
"download_dir": "~/Downloads/ebooks"
}
Run --setup to enter the interactive configuration wizard.
Cookies are cached in ~/.zbook/cookies.json(valid for 24h), avoiding frequent logins that trigger restrictions.
Dependency installation
pip3 install playwright aiohttp --break-system-packages
python3 -m playwright install chromium
How it works
- Login: POST
z-library.sk/rpc.phpto obtain authentication cookies (cached for 24h) - Search: POST
/eapi/book/search, parameter namemessage, form-urlencoded (note: notq, not JSON) - Sort: sort by scoring language + format preference
- Download: Playwright injects cookies, navigates to
/dl/xxxto trigger file download (bypassing Cloudflare)
Notes
- Z-Library free accounts have a daily download limit of 10 books
- The search parameter name is
message(notq), and the format must beapplication/x-www-form-urlencoded - The download endpoint is protected by Cloudflare; pure HTTP requests will get 503, so Playwright must be used
- Frequent logins will trigger the "Too many logins" restriction; the cookie caching mechanism solves this problem