Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Data extraction, also known as web data extraction or web harvesting, is used to collect data from websites and HTML documents. Using the Aspose.HTML for .NET library, you can build C# applications that load HTML documents, inspect DOM elements, use XPath or CSS selectors, save web pages with resources, and download linked files such as images or SVG.
An important part of every extractor is the selector strategy used to find the data in the HTML document. Depending on the page structure, you can navigate the DOM directly, use XPath expressions, query elements with CSS selectors, or combine these approaches.
This Data Extraction section describes how to inspect, capture, save, and extract data from web pages automatically using Aspose.HTML for .NET API.
| Task | Start with |
|---|---|
| Inspect document structure and walk through nodes | HTML Navigation |
| Select elements by tag, class, ID, or attribute | CSS selectors in HTML Navigation |
| Select elements with structured document expressions | XPath queries in HTML Navigation |
| Save a complete web page with linked resources | Website to HTML |
| Download a known resource URL | Save File from URL |
| Extract image or SVG assets from a page | Extract Images From Website or Extract SVG From Website |
| Issue | Cause | Fix |
|---|---|---|
| XPath or CSS selector returns no elements | The selector does not match the loaded HTML, or the target content is produced dynamically. | Inspect the loaded document structure first, then adjust XPath or CSS selectors to the actual DOM available to Aspose.HTML. |
| Relative image, CSS, or SVG URLs are saved incorrectly | The resource URL is resolved without the page base URL. | Use the document URL or base URI when resolving linked resources. |
| Saved website output misses some resources | Resource handling options, URL restrictions, or maximum handling depth prevent downloading related files. | Review HTMLSaveOptions resource handling settings in
Website to HTML. |
| Downloaded files are empty or invalid | The HTTP response status, content type, or redirected URL was not checked. | Check the response before saving and handle redirects, missing resources, and network errors. |
| Extraction behaves differently across websites | HTML structure, script execution, lazy loading, and resource restrictions vary by site. | Treat selectors and resource handling rules as site-specific and validate them against the loaded document. |
Aspose.HTML for .NET is a document processing API, not a dedicated crawling platform. It can load HTML documents and help extract data with DOM navigation, XPath, CSS selectors, and resource handling APIs.
Use CSS selectors for familiar element matching by tag, class, ID, or attribute. Use XPath when the extraction logic depends on document structure, node position, or more expressive path conditions.
It can save a web page and related resources according to HTMLSaveOptions settings such as resource handling, JavaScript behavior, max handling depth, and URL restrictions.
Yes. Use DOM queries to find image or SVG references, resolve resource URLs, and save files with the network APIs or related examples in this section.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.