Skip to content

Instantly share code, notes, and snippets.

@belovachap
Created October 17, 2018 15:28
Show Gist options
  • Save belovachap/b0a223d8eab1ccf99218d34f7e34c4c8 to your computer and use it in GitHub Desktop.
Save belovachap/b0a223d8eab1ccf99218d34f7e34c4c8 to your computer and use it in GitHub Desktop.
check-wallets with threading :)
extern crate reqwest;
extern crate select;
extern crate serde_json;
use select::document::Document;
use select::predicate::{Name, Class, Predicate};
use serde_json::Value;
use std::fs::File;
use std::thread;
fn address_used(address: &String) -> bool {
let url = format!("https://explorer.peercoin.net/address/{}", address);
let result = reqwest::get(&url).unwrap();
let document = Document::from_read(result).unwrap();
return document.find(Name("td").and(Class("danger"))).count() > 0;
}
fn main() {
let file = File::open("/home/chapman/Documents/airdrop_wallet_data.json").unwrap();
let data: Value = serde_json::from_reader(file).unwrap();
let airdrops = data["airdrops"].as_array().unwrap();
let mut threads: Vec<thread::JoinHandle<()>> = Vec::new();
for a in airdrops {
let a = a.as_object().unwrap();
let address = String::from(a["address"].as_str().unwrap());
let handle = thread::spawn(move || {
println!("{}: {}", address, address_used(&address));
});
threads.push(handle);
}
for h in threads {
h.join().unwrap();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment