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.0.tar.gz (34.2 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.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ituring_fetch-0.1.0.tar.gz
  • Upload date:
  • Size: 34.2 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.0.tar.gz
Algorithm Hash digest
SHA256 682ce591d74924d400a8c290d9368551baff8f6fab3d3f1ff450ac63522c1646
MD5 31a8f30706da8f1df7d2dd18f0446e1c
BLAKE2b-256 1cd13774cee741afb797bb6bde49f871f0b54dba6b859930475aa59a95483045

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ituring_fetch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88148820fd7bb18117cf8e048ab6eeb38da2bdb2212f0f98012e68b3eda09701
MD5 10cf1b37d7ef6eed78f4fce1b8fc61ea
BLAKE2b-256 8abcd64b71224fa8581792da67774b20999fae960f6e3d1e14807f01ef45a29e

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