Rust Input Function Example – Easily Compile and Run Dynamic Page Functions
2 min read
Intro:
The Rust Input Function Example actor from Apify.com provides a unique way to run user-defined functions written in the Rust programming language to scrape and extract data from web pages. It's particularly useful for developers seeking to leverage the performance and safety of Rust for web scraping tasks.
🔍 What Is Rust Input Function Example?
The Rust Input Function Example API allows users to execute custom Rust functions to scrape web page content. By dynamically compiling user-provided functions, it enables robust data extraction using Rust's features, such as strong typing and memory safety. This tool is especially beneficial for developers who are already familiar with Rust and want to use this language's capabilities for web scraping applications.
✨ Features
- Dynamic Compilation: Compiles Rust functions at runtime, allowing for custom functionality.
- User-Provided Functions: Accepts user-defined Rust code as input and processes it.
- HTML Scraping: Utilizes the Rust Scraper library to parse HTML documents.
- JSON Output: Returns extracted data in a JSON format using serde_json for easy integration.
- Safe and Fast: Leverages Rust’s performance advantages and safety features.
🛠️ How to Use It
Step-by-step tutorial:
- Go to the tool’s page: Rust Input Function Example
- Click “Try for free” or “Run actor”.
- Fill in the required input fields:
url
: The URL of the page you want to scrape.page_function
: The Rust code function you want to execute on the scraped HTML.
- Click “Run” and wait for results.
- Download results or send to webhook.
🧪 Sample Input (JSON)
json { "url": "https://example.com", "page_function": "fn page_function(document: &Html) -> Value { / Your Rust code here / }" }
📤 Output Data (Fields)
title
: The title of the scraped page.header
: The main header (h1) of the scraped content.companies_using_apify
: A list of companies displayed on the web page (if applicable).
💰 Pricing This actor is priced at $0.005 per run, and it offers a free tier for new users.
👨💻 Built By Lukáš Krivka — from Apify.com
✅ Final Thoughts The Rust Input Function Example is a must-try for developers familiar with Rust who want a powerful and safe tool for web scraping. Its flexibility and performance make it an excellent choice for both simple and complex data extraction tasks.
🔗 Try the Actor Now 👉 Rust Input Function Example