Skip to content

Instantly share code, notes, and snippets.

@belovachap
Created September 27, 2018 04:09
Show Gist options
  • Save belovachap/c4e50e182c474b3306411936339527e8 to your computer and use it in GitHub Desktop.
Save belovachap/c4e50e182c474b3306411936339527e8 to your computer and use it in GitHub Desktop.
Rust program to check the status of Peercoin Airdrop wallets
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;
fn address_used(address: &str) -> 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();
for a in airdrops {
let a = a.as_object().unwrap();
let address = a["address"].as_str().unwrap();
println!("{}: {}", address, address_used(&address));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment