Crates.io | airkorea |
lib.rs | airkorea |
version | 0.4.3 |
source | src |
created_at | 2018-01-19 22:53:14.110063 |
updated_at | 2019-04-15 03:11:18.609414 |
description | Airkorea mobile page crawler |
homepage | |
repository | https://github.com/pbzweihander/airkorea-rs |
max_upload_size | |
id | 47460 |
size | 93,453 |
Airkorea Crawler written in Rust.
use {airkorea, futures::prelude::*, tokio::runtime::Runtime};
let mut rt = Runtime::new();
let status = rt.block_on(airkorea::search(lng, lat))?;
println!("Station address: {}", status.station_address);
println!("Time: {}", status.time);
for pollutant in status {
println!("{}", pollutant);
}
You can override Airkorea Url for mock testing.
If you want to write unit tests for some functions using airkorea,
just set AIRKOREA_URL
environment variable to desired mock server.
spawn_server("localhost:1234");
std::env::set_var("AIRKOREA_URL", "http://localhost:1234");
let status = rt.block_on(airkorea::search(123.123, 456.456)).unwrap();
assert_eq!(&status.station_address, "Foobar Station");