a Rust-based web scraping library for Python
Project description
scraprr
scraprr 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 scraprr::{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 scraprr
opts = scraprr.RequestOptions(
headers={"User-Agent": "XYZ/1.0"},
cookies={"sessionid": "abc123"},
query={"q": "Shrek"}
)
text = scraprr.fetch_url_with_options("https://html.duckduckgo.com/html", opts)
print(text)
Installation:
MacOS arm64
curl -sSL https://raw.githubusercontent.com/dariush-g/scraprr/main/install_scraprr.sh | bash
Linux
pip install scraprr
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.13.tar.gz
(10.4 kB
view details)
Built Distribution
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.13.tar.gz.
File metadata
- Download URL: scraprr-0.1.13.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b28d9e98c0a86ae05e9abcc064fefa59a23dc26be70fa25f3912e677495a3da7
|
|
| MD5 |
4fbb0bcd7554eaf16b9097a1d5f440d4
|
|
| BLAKE2b-256 |
77415c0cc1cb0dba5405fa797adb23dd8417e077e2567df17a27c8a1d6210f80
|
File details
Details for the file scraprr-0.1.13-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: scraprr-0.1.13-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.9 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 |
5b984512f2a3efa151ecd21cef32bc83b25d0f0de1a75b6a4dc151ac08889763
|
|
| MD5 |
2c2baeea4a9ee908ef7e97f82bbd13a7
|
|
| BLAKE2b-256 |
c9a4cf62dbfbb55cb8f590c489b0b5d759a6b84aa8b42e9c930ec9aef6bd32b5
|