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
Release history Release notifications | RSS feed
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.10.tar.gz
(10.2 kB
view details)
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scraprr-0.1.10.tar.gz.
File metadata
- Download URL: scraprr-0.1.10.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c253cf584a9d40f74ad93e2aa407427dab6ede35693316871b616128bf5b59f
|
|
| MD5 |
22465eb2652a25a88b98d8c1d4aadebe
|
|
| BLAKE2b-256 |
5eb3e38d9ddc0e0df8732e285cd9159599cd87936e2072c64a65b070cb875be5
|
File details
Details for the file scraprr-0.1.10-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: scraprr-0.1.10-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9056ca5451bc523174dd8566629d447113915f7a26e23fd34a3cc1039fad4ab5
|
|
| MD5 |
87c766e7591c74b088b24d80b5ea4a54
|
|
| BLAKE2b-256 |
60901403f2981ca5e39c2980e0ab165c951b9fffe2ddffb32ff2bdfce9022f14
|
File details
Details for the file scraprr-0.1.10-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: scraprr-0.1.10-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 241.6 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c112c7d8e33aef3cc91ecaa659dbbfc12b42b68b868b5d2ea5b9c4e45921386
|
|
| MD5 |
a3964c4f1776249e15ba9672cc7b77b0
|
|
| BLAKE2b-256 |
e9275ac68080c27b25f4d0412c40e179e66d9b8cd3f52886a9b450cc5e02ed5c
|