Installation
安装
此页面为 Python 安装 Aspose.HTML FOSS,并使用最小的 DOM 循环验证设置。
Prerequisites
| Requirement | Detail |
|---|---|
| Python | 3.10 或更高版本 |
| pip | 任何最近的版本 |
| 操作系统 | Windows、Linux 或 macOS |
| 原生依赖 | 无 — 纯 Python 实现 |
1. 创建虚拟环境(推荐)
保持安装与系统 Python 隔离:
python -m venv .venv激活它 — 在 Windows 上:
.venv\Scripts\activate在 Linux/macOS 上:
source .venv/bin/activate2. 安装软件包
从 PyPI 安装当前发布版本 (0.1.0):
git clone https://github.com/aspose-html-foss/Aspose.HTML-FOSS-for-Python.git
cd Aspose.HTML-FOSS-for-Python
pip install -e .3. 验证安装
构建一个单元素文档并读取计算后的样式——如果此输出没有错误,则说明安装成功:
from aspose_html.dom import Document
from aspose_html.cssom import CSSStyleSheet
doc = Document()
el = doc.create_element("div")
el.set_attribute("id", "bar")
doc.append_child(el)
sheet = CSSStyleSheet()
sheet.replace_sync("#bar { color: blue }")
doc.attach_style_sheet(sheet)
print(el.get_computed_style().get_property_value("color"))后续步骤
- Quickstart — 构建并美化你的第一个真实文档
- License — MIT 许可证详情
- 功能概览 — 本库涵盖的内容
- DOM 指南 — 文档对象模型深入解析