
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Aspose.HTML for Python via .NET is a powerful API for Python that provides a headless browser functionality, allowing you to work with HTML documents in a variety of ways. With this API, you can easily create new HTML documents or open existing ones from different sources. Once you have the document, you can perform various manipulation operations, such as removing and replacing HTML nodes.
Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support
Aspose.HTML for Python via .NET is a powerful API for Python that provides headless browser functionality, allowing you to work with HTML documents. With this API, you can easily create new HTML documents or open existing ones from different sources. Once you have the document, you can perform various manipulation operations, such as removing and replacing HTML nodes, rendering, and converting HTML to other popular formats, etc.
The following are some popular features of Aspose.HTML for Python via .NET:
<style>
blocks, and external stylesheets within HTML documents.Format | Description | Load | Save |
---|---|---|---|
HTML | HyperText Markup Language format | ✔️ | ✔️ |
XHTML | eXtensible HyperText Markup Language format | ✔️ | ✔️ |
MHTML | MIME HTML format | ✔️ | ✔️ |
EPUB | E-book file format | ✔️ | |
SVG | Scalable Vector Graphics format | ✔️ | ✔️ |
MD | Markdown markup language format | ✔️ | ✔️ |
Portable Document Format | ✔️ | ||
XPS | XML Paper Specification format | ✔️ | |
DOCX | Microsoft Word Open XML document format | ✔️ | |
TIFF | Tagged Image File Format | ✔️ | |
JPEG | Joint Photographic Experts Group format | ✔️ | |
PNG | Portable Network Graphics format | ✔️ | |
BMP | Bitmap Picture format | ✔️ | |
GIF | Graphics Interchange Format | ✔️ | |
WEBP | Modern image format providing both lossy and lossless compression | ✔️ |
Aspose.HTML for Python via .NET can be used to develop applications for a vast range of operating systems, such as Windows, where Python 3.5 or later is installed. You can build both 32-bit and 64-bit Python applications.
Are you ready to give Aspose.HTML for Python via .NET a try?
Simply run pip install aspose-html-net
from the Console to fetch the package.
If you already have Aspose.HTML for Python via .NET and want to upgrade the version, please run pip install --upgrade aspose-html-net
to get the latest version.
You can run the following snippets in your environment to see how Aspose.HTML works, or check out the GitHub Repository or Aspose.HTML for Python via .NET Documentation for other common use cases.
If you want to create an HTML document programmatically from scratch, use the parameterless constructor:
from aspose.html import *
# Initialize an empty HTML document
with HTMLDocument() as document:
# Create a text node and add it to the document
text = document.create_text_node("Hello, World!")
document.body.append_child(text)
# Save the document to a file
document.save("create-new-document.html")
Source - Create a Document in Python
Here is an example of how to use Aspose.HTML for Python via .NET to find images specified by the <img>
element:
import os
from aspose.html import *
from aspose.html.net import *
# Open a document you want to extract images from
with HTMLDocument("https://docs.aspose.com/svg/net/drawing-basics/svg-shapes/") as document:
# Collect all <img> elements
images = document.get_elements_by_tag_name("img")
# Create a distinct collection of relative image URLs
urls = set(element.get_attribute("src") for element in images)
# Create absolute image URLs
abs_urls = [Url(url, document.base_uri) for url in urls]
for url in abs_urls:
# Create an image request message
request = RequestMessage(url)
# Extract image
response = document.context.network.send(request)
# Check whether a response is successful
if response.is_success:
# Parse the URL to get the file name
file_name = os.path.basename(url.pathname)
# Save image to the local file system
with open(os.path.join(file_name), 'wb') as file:
file.write(response.content.read_as_byte_array())
Source - Extract Images From Website in Python
Aspose.HTML for Python via .NET allows you to convert HTML to PDF, XPS, Markdown, MHTML, PNG, JPEG, and other file formats. The following snippet demonstrates the conversion from HTML to PDF literally with a single line of code!
from aspose.html.converters import *
from aspose.html.saving import *
# Convert HTML to PDF
Converter.convert_html("document.html", PdfSaveOptions(), "document.pdf")
Source - Convert HTML to PDF in Python
The following snippet demonstrates the conversion from HTML to GIT-based Markdown (MD) Format:
from aspose.html.converters import *
from aspose.html.saving import *
# Prepare HTML code and save it to the file
code = "<h1>Header 1</h1>" \
"<h2>Header 2</h2>" \
"<p>Hello World!!</p>"
with open('document.html', 'w', encoding="utf-8") as f:
f.write(code)
f.close()
# Call convert_html method to convert HTML to Markdown.
Converter.convert_html('document.html', MarkdownSaveOptions.git, 'output.md')
Source - Creating an HTML Document
The PdfSaveOptions class provides numerous properties that give you full control over a wide range of parameters and improve the process of converting EPUB to PDF format. In the example, we use the page_setup
, jpeg_quality
, and css.media_type
properties:
from aspose.html.converters import *
from aspose.html.saving import *
from aspose.html.drawing import *
# Open an existing EPUB file for reading
with open("input.epub", 'rb') as stream:
# Create an instance of PdfSaveOptions
options = PdfSaveOptions()
options.page_setup.any_page = Page(Size(500, 500), Margin(20, 20, 10, 10))
options.css.media_type.PRINT
options.jpeg_quality = 10
# Convert EPUB to PDF
Converter.convert_epub(stream, options, "output.pdf")
Source - Convert EPUB to PDF in Python
Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License
FAQs
Aspose.HTML for Python via .NET is a powerful API for Python that provides a headless browser functionality, allowing you to work with HTML documents in a variety of ways. With this API, you can easily create new HTML documents or open existing ones from different sources. Once you have the document, you can perform various manipulation operations, such as removing and replacing HTML nodes.
We found that aspose-html-net demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.