Last active
October 20, 2023 21:12
-
-
Save hubert3/6621972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import requests, re | |
btc_rate = 139.0 | |
dollar_total = 0.0 | |
btc_total = 0.0 | |
page = requests.get('http://istouchidhackedyet.com/').text | |
dollar_pledges = re.findall(r'-.+\$(\d+)', page) | |
dollar_total = sum(map(float,dollar_pledges)) | |
btc_pledges = re.findall(r'([\d.]+) bitcoin', page, re.IGNORECASE) | |
btc_total += sum(map(float,btc_pledges)) | |
print '%s USD (%s donors)' % (dollar_total, len(dollar_pledges)) | |
print '%s BTC (%s donors)\n' % (btc_total, len(btc_pledges)) | |
print 'TOTAL $%s' % int(round(dollar_total + btc_total*btc_rate,0)) |
use the right tool and you get the right answer ;-)
#!/usr/bin/perl
use LWP::Simple;
my $btc_rate = 139.0;
$page = get('http://istouchidhackedyet.com/') or die "error download\n";
$page =~ s!^.+?<br/>!!s;
$page =~ s!<p>Terms and Conditions.+?$!!s;
$dollar_cnt++ and $dollar_total += $1 while($page=~s!\$((?:\d*\.)?\d+)! !s);
$dtc_cnt++ and $btc_total += $1 while($page=~s!((?:\d*\.)?\d+)\s*bitcoins?! !is);
$page =~ s!<a[^<>]+>.*?</a>! and !gs;
$page =~ s!<[^<>]+>!!gs;
$page =~ s/\W\s+plus\s+/ and /igs;
$page =~ s/[^\w"']+/ /gs;
$page =~ s/(?:\s*and\s*)+/ and /gs;
$page =~ s/\s*and\s*$//gs;
$page =~ s/\s+/ /gs;
$page =~ s/and/\nand/gs;
printf "%0.02f USD (%u donors)\n",$dollar_total,$dollar_cnt;
printf "%0.02f BTC (%u donors)\n",$btc_total,$dtc_cnt;
printf "TOTAL \$%0.02f\n", $dollar_total + $btc_total * $btc_rate;
print "$page\n";
Better Dollar Counting and prints all the additional Stuff.
Updated with automatic BTC/USD rate from MtGox https://gist.github.com/anthonymonori/6640288
I've been having trouble running it, can someone tell me what it outputs at the moment?
+1 @ezfe's request
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...with extra added hangover calculator!