Skip to content

Commit 5629e95

Browse files
authored
docs: add root README.md, fix links (#9)
1 parent f5f9993 commit 5629e95

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# impit | browser impersonation made simple
2+
3+
impit is a `rust` library that allows you to impersonate a browser and make requests to websites. It is built on top of `reqwest`, `rustls` and `tokio` and supports HTTP/1.1, HTTP/2, and HTTP/3.
4+
5+
The library provides a simple API for making requests to websites, and it also allows you to customize the request headers, use proxies, custom timeouts and more.
6+
7+
```rust
8+
use impit::impit::Impit;
9+
use impit::emulation::Browser;
10+
11+
#[tokio::main]
12+
async fn main() {
13+
let mut impit = Impit::builder()
14+
.with_browser(Browser::Firefox)
15+
.with_http3()
16+
.build();
17+
18+
let response = impit.get(String::from("https://example.com"), None).await;
19+
20+
match response {
21+
Ok(response) => {
22+
println!("{}", response.text().await.unwrap());
23+
}
24+
Err(e) => {
25+
println!("{:#?}", e);
26+
}
27+
}
28+
}
29+
```
30+
31+
### Other projects
32+
33+
If you are looking for a command-line tool that allows you to make requests to websites, check out the [`impit-cli`](https://github.com/apify/impit/tree/master/impit-cli) project.
34+
35+
If you'd prefer to use `impit` from a Node.js application, check out the [`impit-node`](https://github.com/apify/impit/tree/master/impit-node) folder, or download the package from npm:
36+
```bash
37+
npm install impit
38+
```
39+
40+
### Usage from Rust
41+
42+
Technically speaking, the `impit` project is a somewhat thin wrapper around `reqwest` that provides a more ergonomic API for making requests to websites.
43+
The real strength of `impit` is that it uses patched versions of `rustls` and other libraries that allow it to make browser-like requests.
44+
45+
Note that if you want to use this library in your rust project, you have to add the following dependencies to your `Cargo.toml` file:
46+
```toml
47+
[dependencies]
48+
impit = { git="https://github.com/apify/impit.git", branch="master" }
49+
50+
[patch.crates-io]
51+
rustls = { git="https://github.com/apify/rustls.git", branch="impit-patch" }
52+
h2 = { git="https://github.com/apify/h2.git", branch="impit-patch" }
53+
```
54+
55+
Without the patched dependencies, the project won't build.
56+
57+
Note that you also have to build your project with `rustflags = "--cfg reqwest_unstable"`, otherwise, the build will also fail.
58+
This is because `impit` uses unstable features of `reqwest` (namely `http3` support), which are not available in the stable version of the library.

impit/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ async fn main() {
3030

3131
### Other projects
3232

33-
If you are looking for a command-line tool that allows you to make requests to websites, check out the [`impit-cli`](https://github.com/apify/impit-cli/) project.
33+
If you are looking for a command-line tool that allows you to make requests to websites, check out the [`impit-cli`](https://github.com/apify/impit/tree/master/impit-cli) project.
3434

35-
If you'd prefer to use `impit` from a Node.js application, check out the [`impit-node`](https://github.com/apify/impit-node) repository, or download the package from npm:
35+
If you'd prefer to use `impit` from a Node.js application, check out the [`impit-node`](https://github.com/apify/impit/tree/master/impit-node) folder, or download the package from npm:
3636
```bash
3737
npm install impit
3838
```

0 commit comments

Comments
 (0)