Advertisement
Guest User

wcryptprofit.py

a guest
May 14th, 2017
2,337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. #Quick and dirty script created by Matt Graham, @sp4rk2_
  2. #Grabs the BTC transactions to specified BTC addresses.
  3. #Thank you to coinbase and blockchain for pricing information.
  4. import urllib.request
  5. import re
  6.  
  7. def main():
  8. #Place addresses in this array.
  9. address = [ "12t9YDPgwueZ9NyMgw519p7AA8isjr6SMw",
  10. "115p7UMMngoj1pMvkpHijcRdfJNXj6LrLn",
  11. "13AM4VW2dhxYgXeQepoHkHSQuy6NgaEb94",
  12. "1QAc9S5EmycqjzzWDc1yiWzr9jJLC8sLiY",
  13. "15zGqZCTcys6eCjDkE3DypCjXi6QWRV6V1"]
  14.  
  15. #Defines empty variable to calculate total.
  16. totalBTC=0
  17. #Prints the amount of addresses loaded.
  18. print(str(len(address)) + " addresses loaded (using coinbase for pricing)\n")
  19. #Grabs coinbase webpage for BTC to USD price.
  20. with urllib.request.urlopen('https://www.coinbase.com/charts') as response:
  21. #Decodes to readable HTML.
  22. html = str(response.read(), "utf-8")
  23. #Uses regular expression to grab BTC worth from source code.
  24. USD = float(re.search(r"(?<=<span>Bitcoin</span>\n<span class='charts-currency-price'>\n<span class='charts-middot'>&middot;</span>\n<span>\$).*?(?= USD</span>)", html).group(0).replace(",",""))
  25.  
  26. #For every address.
  27. for i in range(len(address)):
  28. #Grab blockchain webpage for the current address.
  29. with urllib.request.urlopen('https://blockchain.info/address/' + address[i]) as response:
  30. #Decodes to readable HTML.
  31. html = str(response.read(), "utf-8")
  32. #Uses regular expression to grab the total received BTC from the source code.
  33. BTC = float(re.search(r'(?<=<td id="total_received"><font color="green"><span data-c=").*?(?= BTC</span>)', html).group(0).split(">")[1])
  34. #Uses regular expression to grab the transaction amount from the source code.
  35. transactions = re.search(r'(?<=<td id="n_transactions">).*?(?=</td>)', html).group(0)
  36. #Prints the address.
  37. print("Address : " + address[i])
  38. #Prints the amount of transactions.
  39. print("Transactions : " + transactions)
  40. #Prints the BTC receieved.
  41. print("BTC received : " + str(BTC) + " BTC")
  42. #Prints the USD received.
  43. print("USD received : " + format(int(BTC * USD), ',f').split(".")[0] + " USD\n")
  44. #Increments totalBTC by the address BTC.
  45. totalBTC += BTC
  46.  
  47. #Prints the total BTC receieved.
  48. print("Total BTC received : " + str(totalBTC) + " BTC")
  49. #Prints the total USD receieved.
  50. print("Total USD received : " + format(int(totalBTC * USD), ',f').split(".")[0] + " USD")
  51.  
  52.  
  53. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement