36 lines
814 B
Rust
36 lines
814 B
Rust
use crate::dsn::parse_dsn_resp;
|
|
use reqwest::blocking::Client;
|
|
use std::collections::HashMap;
|
|
use std::io::BufReader;
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
|
|
mod dsn;
|
|
|
|
fn main() {
|
|
let client = Client::new();
|
|
|
|
let mut params = HashMap::new();
|
|
let timestamp = (SystemTime::now()
|
|
.duration_since(UNIX_EPOCH)
|
|
.unwrap()
|
|
.as_millis()
|
|
/ 5000) as u64;
|
|
params.insert("r", timestamp);
|
|
|
|
let resp = client
|
|
.get("https://eyes.nasa.gov/dsn/data/dsn.xml")
|
|
.query(¶ms)
|
|
.send()
|
|
.unwrap()
|
|
.text()
|
|
.unwrap();
|
|
|
|
let file = BufReader::new(resp.as_bytes());
|
|
|
|
let stations = parse_dsn_resp(file).unwrap();
|
|
|
|
for station in stations {
|
|
println!("Station: {:?}\n Dishes: {:?}", station.name, station.dishes)
|
|
}
|
|
}
|