Allows access to the Zyte API proxy service.
This is an unofficial, unstable, unfinished crate. However normal usage with HTTP GET
should work fine.
async
/await
usage so you must use an async executor e.g. https://github.com/tokio-rs/tokio.bash
cargo add zyte-api-rs
```rust use zyteapirs::ZyteApi;
async fn getgoogle() {
let zyteapi = ZyteApi::new("
// simple GET
let response = zyte_api.get("https://www.google.com/").await.unwrap();
// status_code is from http::Method
if response.status_code.is_success() {
println!("{}", response.http_response_body);
}
let response = zyte_api
.post("https://httpbin.org/post")
.unwrap()
.text(r#"{"custname": "foobar"}"#)
.send()
.await
.unwrap();
if response.status_code.is_success() {
println!("{}", response.http_response_body);
}
}
```
HTTP
GET
POST
httpResponseBody
httpResponseText
Browser
Headers
zyte-api-rs
's Response
object mirror (as much as possible) the structure of the Response
schema from the official api: https://docs.zyte.com/zyte-api/usage/reference.htmlhttp::StatusCode
which allows more useful semantics such as status_code.is_success()
.