Installation

Cài đặt

Trang này cài đặt Aspose.HTML FOSS cho Python và xác minh cài đặt bằng một vòng quay DOM tối thiểu.


Prerequisites

RequirementDetail
Python3.10 hoặc sau này
pipBất kỳ phiên bản gần đây nào
Hệ điều hànhWindows, Linux hoặc macOS
Các phụ thuộc gốcKhông — triển khai Python thuần túy

1. Tạo môi trường ảo (được khuyến nghị)

Giữ việc cài đặt tách biệt khỏi Python hệ thống:

python -m venv .venv

Kích hoạt nó — trên Windows:

.venv\Scripts\activate

Trên Linux/macOS:

source .venv/bin/activate

2. Cài đặt gói

Cài đặt bản phát hành hiện tại (0.1.0) từ PyPI:

git clone https://github.com/aspose-html-foss/Aspose.HTML-FOSS-for-Python.git
cd Aspose.HTML-FOSS-for-Python
pip install -e .

3. Xác minh việc cài đặt

Xây dựng một tài liệu một phần tử và đọc lại kiểu đã tính toán — nếu việc này in ra mà không có lỗi, việc cài đặt đang hoạt động:

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"))

Các bước tiếp theo

Xem thêm

 Tiếng Việt