CGGItemSets/src/main.rs

46 lines
1.2 KiB
Rust
Raw Normal View History

2018-06-04 22:51:18 +02:00
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
extern crate reqwest;
extern crate serde;
extern crate simple_logger;
use std::collections::HashMap;
use reqwest::header::{Headers, UserAgent};
#[derive(Deserialize)]
struct Realm {
v: String,
}
#[derive(Deserialize)]
struct Champion {
data: HashMap<String, ChampInfo>
}
#[derive(Deserialize)]
struct ChampInfo {
id: String,
}
const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0";
fn main() {
simple_logger::init_with_level(log::Level::Info).unwrap();
info!("CGG Item Sets");
let mut headers = Headers::new();
headers.set(UserAgent::new(USER_AGENT));
let client = reqwest::Client::builder().default_headers(headers).build().unwrap();
let realm: Realm = client.get("https://ddragon.leagueoflegends.com/realms/euw.json").send().unwrap().json().unwrap();
info!("LoL version: {}", realm.v);
let champion: Champion = client.get(&format!("http://ddragon.leagueoflegends.com/cdn/{}/data/en_US/champion.json", realm.v)).send().unwrap().json().unwrap();
info!("LoL numbers of champs: {}", champion.data.len());
}