Skip to main content

a Rust-based web scraping library for Python

Project description

scrapr-rs

scrapr-rs is a library for scraping HTML from the web.


Functions

  • Fetch HTML from an HTTP or HTTPS site
  • Extract specific tags (<ul>, <li>, <div>, etc.)
  • Requests with headers, cookies, and query strings

Examples

use scrapr::{fetch_url, fetch_url_with_options, RequestOptions, extract_tag};

fn main() {
    // Basic GET request
    let html = fetch_url("http://localhost:8000/demo.html");
    println!("Raw HTML:\n{}", html);

    // Extract the first <ul> tag and its contents
    let tag = extract_tag(&html, "ul");
    println!("First <ul> tag:\n{}", tag);

    // Custom headers, cookies, and query parameters
    let opts = RequestOptions {
        headers: Some({
            let mut h = std::collections::HashMap::new();
            h.insert("User-Agent".into(), "scrapr/0.1".into());
            h
        }),
        cookies: Some({
            let mut c = std::collections::HashMap::new();
            c.insert("sessionid".into(), "abc123".into());
            c
        }),
        query: Some({
            let mut q = std::collections::HashMap::new();
            q.insert("q".into(), "Rust programming".into());
            q
        }),
    };

    let response = fetch_url_with_options("https://www.wikipedia.org", opts);
    println!("Wikipedia page HTML:\n{}", response);
}
import scrapr_rs

opts = scrapr.RequestOptions(
    headers={"User-Agent": "XYZ/1.0"},
    cookies={"sessionid": "abc123"},
    query={"q": "Shrek"}
)

text = scrapr.fetch_url_with_options("https://html.duckduckgo.com/html", opts)

print(text)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scraprr-0.1.9.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scraprr-0.1.9-cp313-cp313-manylinux_2_34_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

File details

Details for the file scraprr-0.1.9.tar.gz.

File metadata

  • Download URL: scraprr-0.1.9.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.1

File hashes

Hashes for scraprr-0.1.9.tar.gz
Algorithm Hash digest
SHA256 4af5e11c59ce3e37f08f29c790c9e81f152783af0028152d8891616ab69b4ba9
MD5 5a98db0b1ccd67168a28ce6dd151ca61
BLAKE2b-256 123097f419a6753a34a8e10e691dba5ee611badb84815627bc384b3d00e3fde4

See more details on using hashes here.

File details

Details for the file scraprr-0.1.9-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for scraprr-0.1.9-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d95a8d6ca4bf351c5ccb9bd4cf0e43df2d2c3299623855f6e02ce9b2b7c2eb8d
MD5 abbe2f347817e5f158129dc234fce2e5
BLAKE2b-256 bbef910db132a561703bb277c10c1209fb83afb2d7c4702b2a68e09c8f4bf3d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page