Nyzo balance checker

This Python script will allow you to quickly check the balance of multiple public identifiers, there are no requirements for this script to work other than Python 3.

Create a ‘public.txt’ file and put one public-key on each line.
Put this in the same directory as this script and execute.

Please note that this puts 100% trust in the data displayed on nyzo.co

import csv
import requests
block_url = 'http://nyzo.co/block/last'
balance_url = 'https://nyzo.co/balanceListPlain/'
seed_balance = 0
bounty_balance = 0
balance = 0
count = 0

csv_data = [['Public key', 'Current balance']]
with open('balances.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerows(csv_data)

with open('public.txt') as file:
request_url = requests.get(block_url)
page_decoded = request_url.content.decode('utf-8')
start_position = page_decoded.find('

Nyzo block ')
end_position = page_decoded.find('
hash')
block_number = str(page_decoded[start_position + 15: end_position])
print(block_number)
balance_url = balance_url + block_number
request_url = requests.get(balance_url)
print(balance_url)
page_decoded = request_url.content.decode('utf-8')
for line in file:
if len(line) > 10:
public_id_clean = line
public_id = str(line[:67]) + " ∩"
start_position = page_decoded.find(public_id) + 73
end_position = start_position + 25
split_me = (page_decoded[start_position:end_position]).split(" ")

temp_bal = split_me[0]

print(temp_bal)

# addresses with zero balance disappear from the balance list, thus we will grab wrong data
# and attempt to make this a float, this will fail but balance is zero
try:
temp_bal = float(temp_bal)
except:
temp_bal = 0

row = [str(public_id_clean), str(temp_bal)]
balance = balance + temp_bal

# seperate negative and positive per address in csv
with open('balances.csv', 'a', newline='') as file:
writer = csv.writer(file)
writer.writerow(row)

print('Total balance:', str(balance))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.