Skip to content

Repository files navigation

FastWebScrape 0.1.3 [ALPHA] — High-Performance Native HTML/XML Extractor for Java

Status License: MIT Java Platform JitPack


High-performance SIMD/AVX2-powered HTML and XML data-mining engine for the JVM.

FastWebScrape is the data-extraction substrate of the FastJava web stack. It provides highly-optimized native algorithms to strip formatting blocks, find hyperlinks, extract structured tags, and parse JSON-LD schemas in microseconds—bypassing the latency, memory allocations, and heap pressure of traditional heavy DOM parsers.

FastWebScrape Showcase


Quick Start

import fastwebscrape.FastWebScrape;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class Demo {
    public static void main(String[] args) {
        // 1. Open high-speed native AVX2 scraper
        FastWebScrape scraper = FastWebScrape.open();

        byte[] htmlData = ("<html><body><h1>SIMD Architecture</h1>" +
                           "<p>Vector processing on modern CPUs.</p>" +
                           "<a href=\"https://en.wikipedia.org/wiki/AVX-512\">AVX-512 Details</a>" +
                           "</body></html>").getBytes(StandardCharsets.UTF_8);

        // 2. Zero-allocation clean plain text extraction for LLMs
        String cleanText = scraper.extractReadableText(htmlData);
        System.out.println("Clean Text:\n" + cleanText);

        // 3. Ultra-fast hyperlink harvesting
        List<String> links = scraper.extractLinks(htmlData);
        System.out.printf("Harvested %,d hyperlinks in microseconds.\n", links.size());
    }
}

📑 Table of Contents


Key Features

  • ⚡ SIMD/AVX2 Acceleration: Loads 32-byte chunks into CPU vector registers to skip tags and whitespace instantly.
  • 🔍 Zero-Copy Region Locking: Employs GetPrimitiveArrayCritical JNI regions to lock the GC and parse Java arrays directly on the native C++ heap.
  • 🤖 LLM & RAG Optimized: Strips <script>, <style>, and comments while inserting block layout newlines to form clean readable text.
  • ⚙️ Dynamic Runtime CPU Detection: Auto-detects AVX2 using __cpuid at startup with seamless scalar fallback routines for non-AVX2 hardware.

📊 Performance (0.1.0)

Measured on Intel/AMD x64 Hardware with AVX2 instruction support.

Operation Input Size Java (Regex / Standard) FastWebScrape Native (0.1.0) Speedup
Text Strip 5 MB Page ~210 ms ~5 ms 42x
Link Scan 5 MB Page ~45 ms ~2 ms 22x
JSON-LD Pull 5 MB Page ~38 ms ~1 ms 38x

Note

Speedups scale directly with document size due to AVX2 vector unrolling and zero-heap instantiation during native parsing.


API Quick Reference

Method Description Target Path
extractReadableText(...) Cleans document markup and reformats block spacing for LLMs. Reference →
extractLinks(...) Scans for anchor elements and aggregates hyper-links natively. Reference →
extractByTag(...) Finds all elements matching target name and extracts inner content. Reference →
extractJsonLD(...) Isolates all linked JSON-LD metadata schemas concurrently. Reference →

Tip

Use FastWebScrape.open() to obtain the thread-safe native implementation class.


Installation

Option 1: Maven (Recommended)

Add the JitPack repository and the dependencies to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <!-- FastWebScrape Library -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastWebScrape</artifactId>
        <version>0.1.3</version>
    </dependency>

    <!-- FastCore (Required Native Loader) -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastCore</artifactId>
        <version>0.1.0</version>
    </dependency>

    <!-- FastRegex -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastRegex</artifactId>
        <version>0.1.1</version>
    </dependency>
</dependencies>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastWebScrape:0.1.3'
    implementation 'com.github.andrestubbe:FastCore:0.1.0'
    implementation 'com.github.andrestubbe:FastRegex:0.1.1'
}

Option 3: Direct Download (No Build Tool)

Download the latest JARs directly to add them to your classpath:

  1. 📦 FastWebScrape-0.1.3.jar (The Core Library)
  2. ⚙️ fastcore-0.1.0.jar (The Mandatory Native Loader)

Important

All JARs must be in your classpath for the native JNI calls to function correctly.

Technical Examples & Hero Demos

Explore the complete source configurations and benchmarks:

  • ⚡ Interactive Live Stream Demo: Demo.java (.\run-demo.bat) — Multi-article live concurrent ingestion and zero-allocation AVX2 text extraction stream.
  • 📈 Multi-Tier Comparison: Benchmark.java (.\run-compare.bat) — Races FastWebScrape against standard JDK RegEx across 3 tiers (CleanText, Links, Tags).
  • 🚀 OpenJDK JMH Benchmark: FastWebScrapeJmhBenchmark.java (.\run-benchmark.bat) — Formal JMH microbenchmarks measuring ops/ms throughput.
  • 🧪 Test Suite: FastWebScrapeTest.java — Comprehensive JUnit 5 validation.

Run the hero demo locally from the command line:

.\run-demo.bat

Platform Support

Platform Status
Windows 10/11 (x64) ✅ Fully Supported (WinHTTP + AVX2 Native)
Linux 🚧 Planned
macOS 🚧 Planned

Modular Ecosystem

Combine FastWebScrape with other accelerators for maximum efficiency:


License

MIT License — See LICENSE file for details.


Related Projects


Part of the FastJava EcosystemMaking the JVM faster.

About

🕸️ High‑performance native HTML/XML extractor for Java — AVX2‑accelerated parsing, zero‑copy region locking, and microsecond clean‑text extraction for LLM and RAG pipelines.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages