Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Quick and dirty script created by Matt Graham, @sp4rk2_
- #Grabs the BTC transactions to specified BTC addresses.
- #Thank you to coinbase and blockchain for pricing information.
- import urllib.request
- import re
- def main():
- #Place addresses in this array.
- address = [ "12t9YDPgwueZ9NyMgw519p7AA8isjr6SMw",
- "115p7UMMngoj1pMvkpHijcRdfJNXj6LrLn",
- "13AM4VW2dhxYgXeQepoHkHSQuy6NgaEb94",
- "1QAc9S5EmycqjzzWDc1yiWzr9jJLC8sLiY",
- "15zGqZCTcys6eCjDkE3DypCjXi6QWRV6V1"]
- #Defines empty variable to calculate total.
- totalBTC=0
- #Prints the amount of addresses loaded.
- print(str(len(address)) + " addresses loaded (using coinbase for pricing)\n")
- #Grabs coinbase webpage for BTC to USD price.
- with urllib.request.urlopen('https://www.coinbase.com/charts') as response:
- #Decodes to readable HTML.
- html = str(response.read(), "utf-8")
- #Uses regular expression to grab BTC worth from source code.
- USD = float(re.search(r"(?<=<span>Bitcoin</span>\n<span class='charts-currency-price'>\n<span class='charts-middot'>·</span>\n<span>\$).*?(?= USD</span>)", html).group(0).replace(",",""))
- #For every address.
- for i in range(len(address)):
- #Grab blockchain webpage for the current address.
- with urllib.request.urlopen('https://blockchain.info/address/' + address[i]) as response:
- #Decodes to readable HTML.
- html = str(response.read(), "utf-8")
- #Uses regular expression to grab the total received BTC from the source code.
- BTC = float(re.search(r'(?<=<td id="total_received"><font color="green"><span data-c=").*?(?= BTC</span>)', html).group(0).split(">")[1])
- #Uses regular expression to grab the transaction amount from the source code.
- transactions = re.search(r'(?<=<td id="n_transactions">).*?(?=</td>)', html).group(0)
- #Prints the address.
- print("Address : " + address[i])
- #Prints the amount of transactions.
- print("Transactions : " + transactions)
- #Prints the BTC receieved.
- print("BTC received : " + str(BTC) + " BTC")
- #Prints the USD received.
- print("USD received : " + format(int(BTC * USD), ',f').split(".")[0] + " USD\n")
- #Increments totalBTC by the address BTC.
- totalBTC += BTC
- #Prints the total BTC receieved.
- print("Total BTC received : " + str(totalBTC) + " BTC")
- #Prints the total USD receieved.
- print("Total USD received : " + format(int(totalBTC * USD), ',f').split(".")[0] + " USD")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement