vbuterin

Bitcoin charity donation methodology

Dec 23rd, 2012
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import os
  2.  
  3. ## Consumes a text file organized like this:
  4. # http://address1.com
  5. # [address1.com's Bitcoin address]
  6. # http://anotheraddress.org
  7. # [anotheraddress.org's Bitcoin address]
  8. # http://somerandomcharity.net
  9. # [somerandomcharity's Bitcoin address]
  10. ## Outputs:
  11. # http://address1.com [address1.com's Bitcoin address] 123.456789
  12. # http://anotheraddress.org [anotheraddress.org's Bitcoin address] 85.10245
  13. # http://somerandomcharity.net [somerandomcharity's Bitcoin address] 542.9808
  14. ## Assumes:
  15. # A file "prc" contains data in the form "2010-09-06 31.91", describing Bitcoin prices for all dates.
  16. lines = open('addresslist','r').readlines()
  17. prc = {x[:x.find(' ')] : float(x[x.find(' ')+1:].replace('\n','')) for x in open('prc','r').readlines()}
  18.  
  19. o = {}
  20.  
  21. lastname = ''
  22.  
  23. for l in lines:
  24.  
  25.   if l[:4] == 'http': lastname = l.replace('\n','')
  26.   else:
  27.     os.popen('wget -O ff http://blockexplorer.com/address/' + l)
  28.     datalines = os.popen("cat ff | tr '\\n' ' ' | sed 's_</tr>_</tr>\\n_g' | grep Sent | sed 's_</td>_\\t_g' | awk -F '\\t' '{print $2 $3}'| grep -o '(201.*' | awk '{print $1 $3}' | sed 's/^(//g' | sed 's/<td>/ /g'").readlines()
  29.     data = [[x[:x.find(' ')], float(x[x.find(' ')+1:].replace('\n',''))] for x in datalines]
  30.     tot = sum([x[1] * prc[x[0]] for x in data])
  31.     rec = float(os.popen("cat ff | grep -o '<li>Received BTC:[^/]*</li>' | grep -o '[0-9\.]*'").read().replace('\n',''))
  32.     sent = float(os.popen("cat ff | grep -o '<li>Sent BTC:[^/]*</li>' | grep -o '[0-9\.]*'").read().replace('\n',''))
  33.     final = tot + (rec-sent) * prc['2012-12-22']
  34.     o[lastname] = final
  35.     print '%s \t %s \t %f' % (lastname, l.replace('\n',''), final)
Advertisement
Add Comment
Please, Sign In to add comment