Skip to content

Instantly share code, notes, and snippets.

@ummjackson
Created July 31, 2018 02:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ummjackson/377090460bb7f8f5aa20e7b2cbcd312f to your computer and use it in GitHub Desktop.
Save ummjackson/377090460bb7f8f5aa20e7b2cbcd312f to your computer and use it in GitHub Desktop.
import time
import pandas as pd
from selenium import webdriver
# These are the variables which must be calculated by the script.
consensus_distribution = None
wealth_distribution = None
client_codebases = None
public_nodes_source = None
# Tell Selenium to run Chrome in headless mode, with a preset window size
options = webdriver.ChromeOptions()
options.add_argument("headless")
options.add_argument("window-size=1200x600")
# Start driver with specified options
driver = webdriver.Chrome(chrome_options=options)
###################################################
######## ~ You can edit below this point ~ ########
###################################################
###################################################
# Number of entities controllong consensus
###################################################
driver.get("https://www.blockchain.com/pools?timespan=24hours");
time.sleep(1)
# Get data from page
table = driver.find_element_by_id("known_pools")
readtable = pd.read_html(table.get_attribute("outerHTML"), header=0, converters={"count": int})
pools = readtable[0]
# Do calculation
pools["cumulative_sum"] = pools["count"].cumsum()
pools["cumulative_percentage"] = 100 * pools["cumulative_sum"] / pools["count"].sum()
# Set the variable
consensus_distribution = pools[pools["cumulative_percentage"].gt(51)].index[0] + 1
print(consensus_distribution)
###################################################
# Wealth distribution
###################################################
driver.get("https://bitinfocharts.com/bitcoin/");
time.sleep(1)
# Get data from page
wealth_text = driver.find_element_by_id("tdid18").text
cleaned_text = wealth_text.replace(" ", "").split('/')
wealth_distribution = cleaned_text[1]
print(wealth_distribution)
###################################################
# Client Codebases
###################################################
# TBD
###################################################
# Public Nodes
###################################################
# TBD
# Close the driver
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment