Skip to main content

CLI tool to scrape purchased ebooks from ituring.com.cn

Project description

ituring-fetch

把图灵社区已购电子书扒下来,转成 epub/pdf/html。

安装

git clone <repo>
cd ituring_fetch
uv sync
playwright install chromium   # 或者用系统自带的 Chrome

依赖:Python 3.11+、pandoc(epub 格式需要)、Chrome/Chromium。

使用

# 登录(会弹出浏览器窗口)
uv run ituring-fetch login

# 看看登录没
uv run ituring-fetch status

# 列出已购电子书
uv run ituring-fetch list

# 抓取一本书
uv run ituring-fetch fetch 1143 --type=epub
uv run ituring-fetch fetch 1143 --type=pdf
uv run ituring-fetch fetch 1143 --type=html

# 指定输出文件名
uv run ituring-fetch fetch 1143 --type=pdf -o mybook.pdf

# 登出
uv run ituring-fetch logout

list 输出的第一列就是书籍 ID。

调试

出问题时设个环境变量看详细日志:

ITURING_DEBUG=1 uv run ituring-fetch fetch 1143 --type=pdf

会往 stderr 打请求/响应细节。

原理

登录时用 Playwright 打开浏览器,你手动登录后,程序从 localStorage 里取出 access token,跟 cookie 一起存到 ~/.ituring/credentials.json

后续操作:

  • list 和书籍信息直接调 api.ituring.com.cn 的接口,带 Bearer token
  • 章节内容用 Playwright headless 渲染页面,抽 .article-content 的 HTML
  • 合并所有章节,pandoc 转 epub,Playwright 内置 PDF 引擎出 pdf

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ituring_fetch-0.1.1.tar.gz (63.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ituring_fetch-0.1.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file ituring_fetch-0.1.1.tar.gz.

File metadata

  • Download URL: ituring_fetch-0.1.1.tar.gz
  • Upload date:
  • Size: 63.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ituring_fetch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 79a4cbe1d961f7a19d184eb406e3790b9380fe3e7eec738369943e95d7363572
MD5 15df047b1bf5003424a39ee08fbb27fc
BLAKE2b-256 9644780341e17844e3cf00aafb0eb05c62e8c1a67897524fb4176a8b1b214373

See more details on using hashes here.

File details

Details for the file ituring_fetch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ituring_fetch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ituring_fetch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 296b724eb88bb64215ec05f9c8827b36032ec44e25cd119cffa7871e1115000e
MD5 8e322be771687e912118598685cf819f
BLAKE2b-256 f279962135b3f681e9530fb4b9d1d4e667fc061d7eb4117ff5c68cf5831cbf86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page