Skip to main content

北京化工大学课程平台PDF下载工具,支持登录、下载PPT和PDF文件

Project description

buct-pdf

北京化工大学课程平台PDF下载工具,支持登录、下载PPT和PDF文件。

功能特性

  • 🔐 自动登录北化课程平台
  • 📄 下载PPT文件并转换为PDF
  • 📥 直接下载PDF文件
  • 🖥️ 命令行界面支持
  • 📦 可作为Python库导入使用

安装

使用 pip 安装

pip install buct-pdf

从源码安装

git clone https://github.com/your-username/buct-pdf.git
cd buct-pdf
pip install -e .

使用方法

作为命令行工具

交互式模式(推荐)

buct-pdf -i

直接使用(保持原有体验)

python buct-pdf.py

作为Python库

from buct_pdf import GetsPdf, LoginError, NetworkError

# 创建下载器实例
downloader = GetsPdf()

try:
    # 登录
    downloader.login("your_student_id", "your_password")
    
    # 下载PPT并转换为PDF
    ppt_url = "https://course.buct.edu.cn/meol/analytics/resPdfShow.do?resId=12345&lid=67890"
    pdf_path = downloader.download_ppt_to_pdf(ppt_url, "./downloads")
    print(f"PPT下载完成: {pdf_path}")
    
    # 直接下载PDF文件
    pdf_url = "https://course.buct.edu.cn/meol/analytics/resPdfShow.do?resId=54321&lid=09876"
    pdf_path = downloader.download_pdf(pdf_url, "./downloads")
    print(f"PDF下载完成: {pdf_path}")
    
except LoginError as e:
    print(f"登录错误: {e}")
except NetworkError as e:
    print(f"网络错误: {e}")
finally:
    # 注销登录
    downloader.logout()

API文档

GetsPdf 类

主要的下载器类,提供所有核心功能。

方法

  • login(username, password): 登录到北化课程平台
  • logout(): 注销登录
  • is_logged_in(): 检查登录状态
  • download_ppt_to_pdf(url, output_dir="."): 下载PPT并转换为PDF
  • download_pdf(url, output_dir="."): 直接下载PDF文件
  • set_base_url(base_url): 设置基础URL(用于测试)
  • get_session(): 获取认证后的session对象

异常类

  • LoginError: 登录相关错误
  • NetworkError: 网络相关错误

开发

环境设置

# 克隆仓库
git clone https://github.com/your-username/buct-pdf.git
cd buct-pdf

# 创建虚拟环境
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# 安装开发依赖
pip install -e .

运行测试

python -m pytest tests/

代码格式化

black buct_pdf/
ruff check buct_pdf/

项目结构

buct-pdf/
├── buct_pdf/           # 主要库代码
│   ├── __init__.py    # 库入口
│   ├── core.py        # 核心功能实现
│   └── cli.py         # 命令行接口
├── examples/          # 使用示例
├── tests/            # 测试代码
├── buct-pdf.py       # 兼容性脚本
├── pyproject.toml    # 项目配置
└── README.md         # 项目说明

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v0.1.0

  • 初始版本发布
  • 支持登录、PPT下载和PDF下载功能
  • 提供命令行和Python库两种使用方式

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

buct_pdf-0.6.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

buct_pdf-0.6.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file buct_pdf-0.6.0.tar.gz.

File metadata

  • Download URL: buct_pdf-0.6.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for buct_pdf-0.6.0.tar.gz
Algorithm Hash digest
SHA256 43503e228f1fa11bd9c2ac35acf026de6df5a6aaf7d232d4cf14534981231ec6
MD5 d5bd896777deed496b71c6e5cc29af1d
BLAKE2b-256 49d82b73987bc02172597d8cd8caf543ddf2c620edd3303b00e0e08a1ece9a68

See more details on using hashes here.

File details

Details for the file buct_pdf-0.6.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for buct_pdf-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f448db5de86f9002e980b4b6dc20ba2b6bd5c39dfef495e0c69fbd3b74dea5cb
MD5 342b506d9060588f0709b6c76bf2480e
BLAKE2b-256 8c366861e915f1b0b1bd0ea85bb81806dc256e277caeaee27fdfdc1c01227bb1

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