Add getfromnet example
This commit is contained in:
parent
6e471a17e2
commit
0ba4168b85
2 changed files with 19 additions and 0 deletions
|
@ -12,3 +12,6 @@ chrono = { version = "0.4.19", features = ["std", "serde"], default-features = f
|
||||||
serde = { version = "1.0.126", features = ["derive"] }
|
serde = { version = "1.0.126", features = ["derive"] }
|
||||||
serde_json = "1.0.64"
|
serde_json = "1.0.64"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["blocking"] }
|
||||||
|
|
16
examples/getfromnet.rs
Normal file
16
examples/getfromnet.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
use wikidata::*;
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
for i in 1_usize.. {
|
||||||
|
let uri = format!("https://www.wikidata.org/wiki/Special:EntityData/Q{}.json", i);
|
||||||
|
let res = reqwest::blocking::get(uri).unwrap();
|
||||||
|
let text = res.text().unwrap();
|
||||||
|
if text.contains("<h1>Not Found</h1><p>No entity with ID ") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let ent = Entity::from_json(serde_json::from_str(&text).unwrap()).unwrap();
|
||||||
|
let _ = ent;
|
||||||
|
println!("verified Q{}", i);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue