读取 HTML 文档的任务是读取 DOM 模型中的分层数据结构的任务。这意味着了解每个单独的 HTML 数据元素的格式,包括其所有可能的子元素和属性。
我们的 Python 库是一个基于云的解决方案,可让您轻松打开 HTML 文件进行读写。这种分布式方法使您可以灵活地使用 Python 语言进行软件开发,因为所有资源密集型 HTML 文档处理都将在 Aspose 服务器上进行。您只需要获取私钥即可在 Python 代码中访问 Cloud API。
您可以遍历 HTML 文档的所有元素,也可以在 DOM 树中搜索特定元素。我们提供了广泛的 Python 函数,用于处理 HTML 文件的结构和文档节点中包含的数据。
以下代码示例将帮助您快速了解如何使用 Python 加载 HTML 文件并对其执行一些操作。
import asposewordscloud
words_api = WordsApi(client_id = '####-####-####-####-####', client_secret = '##################')
file_name= 'Input.html'
request_file_content = open(open(file_name).read(), 'rb')
upload_document_request = asposewordscloud.models.requests.UploadFileRequest(
file_content=request_file_content, path=file_name)
words_api.upload_file(upload_document_request)
request_paragraph = asposewordscloud.ParagraphInsert(
text='Reading and writing to the file in the cloud occurs automatically.')
insert_paragraph_request = asposewordscloud.models.requests.InsertParagraphRequest(
name=file_name, paragraph=request_paragraph)
words_api.insert_paragraph(insert_paragraph_request)
download_document_request = asposewordscloud.models.requests.DownloadFileRequest(
path=file_name)
words_api.download_file(download_document_request)
使用 PyPi 存储库安装 Aspose.Words Cloud SDK for Python 。运行 pip install aspose-words-cloud 安装 SDK,然后通过 import asposewordscloud 导入包。作为替代方案,您可以从 GitHub 手动克隆 Aspose.Words Cloud SDK for Python 源代码并在您的项目中使用它。请按照这些 Instructions 快速获取必要的安全凭证并访问我们的 REST API。
请参阅 Repository Documentation 以查看详细信息。