Crates.io | zyte-api-rs |
lib.rs | zyte-api-rs |
version | 0.2.0 |
source | src |
created_at | 2023-05-16 23:51:52.126025 |
updated_at | 2023-05-25 23:50:18.722824 |
description | Use the Zyte API Proxy -- Unofficial & Unstable |
homepage | https://github.com/isaacimholt/zyte-api-rs |
repository | https://github.com/isaacimholt/zyte-api-rs |
max_upload_size | |
id | 866426 |
size | 18,004 |
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.cargo add zyte-api-rs
use zyte_api_rs::ZyteApi;
#[tokio::main]
async fn get_google() {
let zyte_api = ZyteApi::new("<MY_ZYTE_API_KEY>");
// 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()
.