3 stable releases
new 4.0.2 | Dec 15, 2024 |
---|---|
4.0.1 | Nov 26, 2024 |
3.0.0 |
|
2.1.1 |
|
0.1.0 |
|
#792 in Web programming
361 downloads per month
59KB
1K
SLoC
dot4ch
dot4ch is a convenient wrapper library around an imageboard's API.
This library can fetch and update:
- Threads
- Boards
- Catalogs
While respecting:
- GET 1 second-per-request cooldown.
If-Modified-Since
headers with update requests.- 10 seconds per thread update rate limits.
Getting Started
Examples can be found in the examples directory.
You can run any example with
cargo run --example <example name>
MSRV
Rust MSRV: 1.70.1 Edition: 2021
lib.rs
:
dot4ch
dot4ch is a convenient wrapper library around an imageboard's read-only API.
This library can fetch and update:
While respecting:
- 1 second-per-request rate-limits.
If-Modified-Since
headers with update requests.- 10 seconds per thread update rate limits.
Example: Printing the comment from a thread.
use dot4ch::thread::Post;
use dot4ch::thread::Thread;
use dot4ch::Client;
#[tokio::main]
async fn main() -> Result<()> {
let client = Client::new();
let mut thread = Thread::new(&client, "po", 570368).await?;
// update thread
thread.update(&client).await?;
// print thread's OP comment
let comment = thread.first().and_then(Post::com).unwrap();
let comment = comment.replace("<br>", "\n"); // replace line breaks
println!("op says: {comment}");
Ok(())
}
Dependencies
~6–17MB
~226K SLoC