Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use WWW::Mechanize;
- use WWW::Mechanize::Firefox;
- use HTTP::Cookies;
- use Data::Dumper;
- use Term::ReadKey;
- use Spreadsheet::WriteExcel;
- binmode(STDOUT, ":utf8");
- #ZENscrape v1.46 by Cryptichermit
- #ZENscrape v1.46 Increases NET::Telnet timeout to reduce timeout errors.
- #ZENscrape v1.46 Fixes Transaction ID for Hashlets that had no payout.
- #ZENscrape v1.45 Reconciles Double Hash payout records.
- #ZENscrape v1.45 Change check record to look for any change in records value instead of incremental value.
- #ZENscrape v1.44 JSON changes made to transaction ID in some new records - reconciled.
- #ZENscrape v1.44 JSON changes made to zenhashlet payout - reconciled.
- #ZENscrape v1.44 added SSL name verification bypass back into BTC ticker, some platforms were failing.
- #ZENscrape v1.43 includes new Checksum for new ZENcloud multi-output payout details.
- #ZENscrape v1.42 incorporates WWW::Mechanize::Firefox module to attach to firefox browser session
- #ZENscrape v1.42 Removes some no longer needed since authentication is done on firefox browser session
- #ZENscrape v1.42 Corrects 1 account error with hashpoints, 1 error with excel call for Microsoft office users.
- #ZENscrape v1.41 includes accounting of HashPool HashPoint payouts.
- #ZENscrape v1.41 includes SSL name verification bypass, and 2 small syntax fixes.
- #ZENscrape v1.41 fix on zencon subroutine for authy token failure.
- #ZENscrape v1.4 moves to CLI (command line interface).
- #ZENscrape keeps an active connection with your ZENportal Dashboard.
- #Realtime BTC values are displayed. New records are automatically imported.
- #Run multlipe reports and export to CSV with a single keyboard stroke.
- #Show and chart Income vs. Expense.
- my $ssoft = "LO"; #set to LO for Libreoffice and MO for Microsoft Office.
- my $btcval = 0; #leave 0 for it to auto grab BTC price from bitstamp or enter your desired BTC value to compare
- my $zenapi = 'zenapi.txt'; #this is JSON API output file. It is required for storing JSON data.
- my $ver = "v1.46";
- my $btcurl = "https://api.bitcoinaverage.com/ticker/USD/last";
- $| = 1;
- my $pof = "ZEN_pay.csv";
- my $chf = "ZEN_charges.csv";
- my $zpf = "ZEN_pur.csv";
- my $hpf = "ZEN_HP.csv";
- my $zdf = "ZEN_dep.csv";
- my $zwf = "ZEN_wdraw.csv";
- my $zsf = "ZEN_sold.csv";
- my $btdash='';
- my $usdash='';
- my $hpdash='';
- my $payouts = 0;
- my $hpout = 0;
- my $hp = 0;
- my $hpup = 0;
- my $hpdown = 0;
- my $hpdzen = 0;
- my $pay = 0;
- my $fees = 0;
- my $numfee = 0;
- my $sval = '0';
- my $pur = 0;
- my $hppur = 0;
- my $btcpur = 0;
- my $usdpur = 0;
- my $wdraw = 0;
- my $btcwd = 0;
- my $xfers = 0;
- my $btcin = 0;
- my $hsold = 0;
- my $valsold = 0;
- my $btcsold = 0;
- my $recmia = 0;
- my $profit = 0;
- my $key='';
- my $uid='';
- my $mech = WWW::Mechanize::Firefox->new();
- $mech->repl->repl->client->{telnet}->timeout(90);
- my $bmech = WWW::Mechanize->new(ssl_opts => { verify_hostname => 0 }, autocheck => 1);
- my $c='';
- my $e='';
- my $rectime=10;
- my $recval=0;
- my $dashtime=2;
- my $dashval=0;
- my $locrec = 0;
- my $data = '';
- my $sdata = '';
- my $numrec = '0';
- my $loaded = 0;
- my $rdate = '';
- my $upok = 0;
- my $hpay = 0;
- sub cpos
- {
- local($a, $b) = ($_[0], $_[1]);
- printf("\033[%d;%dH", $a, $b);
- }
- sub rstr
- {
- local($a, $b) = ($_[0], $_[1]);
- foreach my $i (1..$b)
- {
- print $a;
- }
- }
- sub fstr
- {
- my($a, $b, $c) = ($_[0], $_[1], $_[2]);
- rstr($a,$b-length($c));
- print $c;
- }
- sub bstr
- {
- my($a, $b, $c) = ($_[0], $_[1], $_[2]);
- print $c;
- rstr($a,$b-length($c));
- }
- sub tcol
- {
- local($a) = ($_[0]);
- if ($a eq "black") {printf "\x1B[30m";}
- if ($a eq "blue") {printf "\x1B[34m";}
- if ($a eq "green") {printf "\x1B[32m";}
- if ($a eq "yellow") {printf "\x1B[33m";}
- if ($a eq "purple") {printf "\x1B[35m";}
- if ($a eq "cyan") {printf "\x1B[36m";}
- if ($a eq "") {printf "\x1B[37m";}
- }
- sub bcol
- {
- local($a) = ($_[0]);
- if ($a eq "black") {printf "\x1B[40m";}
- if ($a eq "blue") {printf "\x1B[44m";}
- if ($a eq "green") {printf "\x1B[42m";}
- if ($a eq "yellow") {printf "\x1B[43m";}
- if ($a eq "purple") {printf "\x1B[45m";}
- if ($a eq "cyan") {printf "\x1B[46m";}
- if ($a eq "white") {printf "\x1B[47m";}
- if ($a eq "red") {printf "\x1B[41m";}
- if ($a eq "") {printf "\x1B[0m";}
- }
- sub clrscr
- {
- bcol("black");
- printf("%c[2J",27);
- printf("\033\143");
- cpos(0, 0);
- }
- sub prompt
- {
- my ($text) = @_;
- print $text;
- my $answer = <STDIN>;
- chomp $answer;
- return $answer;
- }
- sub btcv
- {
- my $res = $bmech->get($btcurl);
- if ($res->is_success()) {$btcval = $bmech->content();}
- else
- {
- bcol("red");
- tcol("");
- dbox(80,"BTC Ticker Connection Failed",25,20,"","red");
- cpos(27,20);
- fstr(".",79,"Will Re-try connection in");
- foreach my $i (1..9)
- {
- print 10-$i;
- sleep(1);
- cpos(27,99);
- }
- btcv();
- }
- }
- sub dbox
- {
- my($a, $c, $x, $y,$tc,$bc) = ($_[0], $_[1], $_[2], $_[3], $_[4], $_[5]);
- tcol($tc);
- bcol($bc);
- cpos($x,$y);
- my $pad=sprintf("%.0f",($a-length($c))/2);
- rstr(" ",$pad);
- print $c;
- if ($pad+$pad+length($c) == $a) {rstr(" ",$pad);}
- else {rstr(" ",$pad+1);}
- cpos($x+1,$y);
- rstr("=",$a);
- cpos($x+2,$y);
- }
- sub zencon
- {
- bcol("red");
- tcol("");
- dbox(80,"Disconnected from ZEN-Cloud - Re-Authorization Required",25,20,"","red");
- cpos(27,20);
- bstr(".",80,"In Firefox re-connect to your ZENcloud account. Then hit a key here.");
- while (!defined( $key = ReadKey(-1))) {sleep(1);}
- my $url = "https://cloud.zenminer.com/api/activity?iDisplayStart=0&iDisplayLength=1";
- my $res = $mech->get($url);
- if ($res->is_success())
- {
- my $findat = Dumper ($mech->content());
- if (index($findat, '"iTotalRecords":') == -1)
- {
- cpos(27,20);
- rstr(" ",80);
- cpos(27,20);
- fstr(".",80,"There is still a problem. Retry in 3 seconds.");
- sleep(3);
- zencon();
- }
- }
- else {zencon();}
- }
- sub dash
- {
- my $finurl = "https://cloud.zenminer.com/dashboard/$uid";
- my $res = $mech->get($finurl);
- if ($res->is_success())
- {
- my $findat = Dumper ($mech->content());
- if (index($findat, '<body class="login-page">') == -1)
- {
- $c = index($findat, '"balance-value\"> ');
- $e = index($findat, '</span><span class=\"balanceAbbr-value', $c);
- $c = $c+19;
- $sval = substr($findat,$c,$e-$c);
- $btdash = $sval;
- $c = index($findat, '"balanceUSD-value\">');
- $e = index($findat, '<span class=\"denom\"> USD', $c);
- $c = $c+20;
- $sval = substr($findat,$c,$e-$c);
- $usdash = $sval;
- $c = index($findat, '"balanceZP-value\"> ');
- $e = index($findat, '<span class=\"denom\"> HP', $c);
- $c = $c+21;
- $sval = substr($findat,$c,$e-$c);
- $hpdash = $sval;
- }
- else
- {
- zencon();
- }
- }
- else
- {
- zencon();
- }
- }
- sub sortcsv
- {
- open (DATA, $_[0]);
- my @rows = map { chomp; [split /,/, $_] } <DATA>;
- my @sorted = sort { $b->[0] cmp $a->[0] || $b->[1] cmp $a->[1] } @rows;
- close DATA;
- open (WF,">",$_[0]);
- for (@sorted) {
- print WF join(',', @$_) . "\n"; # print them out as CSV
- }
- close WF;
- }
- sub gdate
- {
- open (CSVF, $pof);
- my $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- if ($row == 1) {$rdate = $Fld[0];}
- $row++;
- }
- close CSVF;
- }
- sub tdayxls
- {
- my $wb = Spreadsheet::WriteExcel->new("ZEN_$rdate.xls");
- my $wk = $wb->addworksheet('Profits');
- $wk->set_column('A:A',25);
- $wk->set_column('B:C',12);
- $wk->write(0,0,"Miner");
- $wk->write(0,1,"Payout");
- $wk->write(0,2,"Fees");
- my $numval = $wb->add_format();
- $numval->set_num_format('0.00000000');
- open (CSVF, $pof);
- my $row = 1;
- my $rowp = 1;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- if ($Fld[0] eq $rdate)
- {
- my $col = 0;
- foreach (@Fld)
- {
- if ($col == 2) {$wk->write($row, 0, $Fld[2]);}
- elsif ($col == 3) {$wk->write($row, 1, $Fld[3], $numval);}
- $col++;
- }
- $rowp++;
- $row++;
- }
- }
- close CSVF;
- open (CSVF, $chf);
- $row = 1;
- my $rowf = 1;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- if ($Fld[0] eq $rdate)
- {
- my $col = 0;
- foreach (@Fld)
- {
- if ($col == 2) {$wk->write($row, 2, $Fld[3], $numval);}
- $col++;
- }
- $rowf++;
- $row++;
- }
- }
- close CSVF;
- my $numper = $wb->add_format();
- $numper->set_num_format('0.00%');
- $row=$rowp+1;
- if ($rowf > $rowp) {$row=$rowf+1;}
- $wk->write($row+1, 0, "Total");
- $wk->write_formula($row+1, 1, "=SUM(B2:B$row)", $numval);
- $wk->write_formula($row+1, 2, "=SUM(C2:C$row)", $numval);
- $row=$row+2;
- $wk->write_formula($row, 2, "=C$row/B$row", $numper);
- $wk->write($row+1, 0, "Profits");
- $rowf=$row+1;
- $rowp=$row+2;
- $wk->write_formula($row+1, 1, "=B$row-C$row", $numval);
- $wk->write_formula($row+2, 1, "=B$rowp/B$row", $numper);
- my $chart = $wb->add_chart( type => 'column',embedded => 1 );
- $chart->add_series(
- name => 'Payout',
- values => "=Profits!\$B\$$row:\$B\$$row"
- );
- $chart->add_series(
- name => 'Fees',
- values => "=Profits!\$C\$$row:\$C\$$row"
- );
- $row=$row+2;
- $chart->add_series(
- name => 'Profit',
- values => "=Profits!\$B\$$row:\$B\$$row"
- );
- $chart->set_title( name => "ZENcloud Payout for $rdate");
- $chart->set_x_axis( name => "Chart created by ZENscrape $ver");
- $chart->set_y_axis( name => 'BTC' );
- $wk->insert_chart( 'E2', $chart );
- $wb->close();
- }
- sub bdayxls
- {
- open (DCSVF, $pof);
- my $brow = 0;
- my $nday = 0;
- while (<DCSVF>)
- {
- chomp;
- my @dfld = split(',', $_);
- if ($brow == 1) {$rdate = $dfld[0];}
- if ($rdate ne $dfld[0]) {$rdate=$dfld[0];$nday++}
- tdayxls();
- $brow++;
- cpos(32,80);
- fstr(".",5,$nday);
- }
- close DCSVF;
- }
- sub chartxls
- {
- open (DATA, $pof);
- my @rows = map { chomp; [split /,/, $_] } <DATA>;
- my @srt = sort { $a->[0] cmp $b->[0] } @rows;
- close DATA;
- open (WF,">","temp.csv");
- for (@srt) {
- print WF join(',', @$_) . "\n";
- }
- close WF;
- my $wb = Spreadsheet::WriteExcel->new("ZEN_chart.xls");
- my $wk = $wb->addworksheet('Chart');
- $wk->set_column('A:D',12);
- my $numval = $wb->add_format();
- $numval->set_num_format('0.00000000');
- my $numper = $wb->add_format();
- $numper->set_num_format('0.00%');
- $wk->write(0,0,"Date");
- $wk->write(0,1,"Payout");
- $wk->write(0,2,"Fees");
- $wk->write(0,3,"Profit");
- $wk->write(1,2,"0",$numval);
- my $row = 0;
- my $pday = 0;
- my $cdate='';
- $rdate='';
- open (CSVF, "temp.csv");
- my $rowp = 1;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- if ($row == 0) {$rdate = $Fld[0];$cdate=$rdate;}
- if ($Fld[0] eq $rdate)
- {
- $pday=$pday+$Fld[3];
- }
- else
- {
- $wk->write($rowp, 0, $rdate);
- $wk->write($rowp, 1, $pday, $numval);
- $rdate=$Fld[0];
- $pday=$Fld[3];
- $rowp++;
- }
- $row++;
- }
- close CSVF;
- open (DATA, $chf);
- @rows = map { chomp; [split /,/, $_] } <DATA>;
- @srt = sort { $a->[0] cmp $b->[0] } @rows;
- close DATA;
- open (WF,">","temp.csv");
- for (@srt) {
- print WF join(',', @$_) . "\n";
- }
- close WF;
- $row = 0;
- $pday = 0;
- $rdate=$cdate;
- open (CSVF, "temp.csv");
- $rowp = 1;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- if ($Fld[0] eq $rdate)
- {
- $pday=$pday+$Fld[3];
- }
- elsif ($pday != 0)
- {
- $wk->write($rowp, 2, $pday, $numval);
- $rdate=$Fld[0];
- $pday=$Fld[3];
- $rowp++;
- }
- elsif ($Fld[0] ne "DATE")
- {
- $rdate=$Fld[0];
- $pday=$pday+$Fld[3];
- $rowp++;
- }
- $row++;
- }
- unlink ("temp.csv");
- foreach $row (2..$rowp)
- {
- $wk->write_formula($row-1,3,"=B$row-C$row", $numval);
- }
- my $chart = $wb->add_chart( type => 'line',embedded => 1 );
- $chart->add_series(
- name => 'Payout',
- values => "=Chart!\$B\$2:\$B\$$rowp"
- );
- $chart->add_series(
- name => 'Fees',
- values => "=Chart!\$C\$2:\$C\$$rowp"
- );
- $row=$row+2;
- $chart->add_series(
- name => 'Profit',
- values => "=Chart!\$D\$2:\$D\$$rowp"
- );
- $chart->set_title( name => "ZENcloud Historical Payout Chart.");
- $chart->set_x_axis( name => "Chart created by ZENscrape $ver");
- $chart->set_y_axis( name => 'BTC' );
- $wk->insert_chart( 'E2', $chart, 0, 0, 3.0, 1.75);
- $wb->close();
- }
- sub createxls
- {
- my $wb = Spreadsheet::WriteExcel->new("ZEN.xls");
- my $wk = $wb->addworksheet('Payouts');
- $wk->set_column('A:B',12);
- $wk->set_column('C:C',25);
- $wk->set_column('D:D',12);
- $wk->set_column('E:F',25);
- open (CSVF, $pof);
- my $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- $wk = $wb->addworksheet('Fees');
- $wk->set_column('A:B',12);
- $wk->set_column('C:C',25);
- $wk->set_column('D:D',12);
- $wk->set_column('E:E',25);
- open (CSVF, $chf);
- $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- $wk = $wb->addworksheet('Purchases');
- $wk->set_column('A:E',12);
- open (CSVF, $zpf);
- $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- $wk = $wb->addworksheet('HashPoints');
- $wk->set_column('A:C',12);
- $wk->set_column('D:D',50);
- open (CSVF, $hpf);
- $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- $wk = $wb->addworksheet('Deposits');
- $wk->set_column('A:C',12);
- $wk->set_column('D:D',25);
- open (CSVF, $zdf);
- $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- $wk = $wb->addworksheet('Withdrawals');
- $wk->set_column('A:C',12);
- $wk->set_column('D:D',25);
- open (CSVF, $zwf);
- $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- $wk = $wb->addworksheet('Sold');
- $wk->set_column('A:C',12);
- open (CSVF, $zsf);
- $row = 0;
- while (<CSVF>)
- {
- chomp;
- my @Fld = split(',', $_);
- my $col = 0;
- foreach my $token (@Fld)
- {
- $wk->write($row, $col, $token);
- $col++;
- }
- $row++;
- }
- close CSVF;
- }
- sub crec
- {
- my $url = "https://cloud.zenminer.com/api/activity?iDisplayStart=0&iDisplayLength=1";
- my $res = $mech->get($url);
- if ($res->is_success())
- {
- my $outpage = Dumper ($mech->content());
- if (index($outpage, '"iTotalRecords":') == -1) {zencon()};
- $c = index($outpage, '"iTotalRecords":');
- $c = $c+16;
- $e = index($outpage, ',"aaData"');
- $numrec = substr($outpage,$c,$e-$c);
- if ($locrec > 0) {$outpage = '';}
- if ($numrec != $locrec)
- {
- dbox(50,"NEW RECORDS FOUND",30,35,"","blue");
- bstr(".",50,"Collecting Data.");
- sleep(1);
- $url = "https://cloud.zenminer.com/api/activity? iDisplayStart=0&iDisplayLength=i";
- $res = $mech->get($url);
- if ($res->is_success())
- {
- $outpage = Dumper ($mech->content());
- if (index($outpage,'createdAt') == -1) {zencon();}
- $locrec=$numrec;
- $data=$outpage;
- }
- else {zencon();}
- }
- else
- {
- dbox(50,"No new Records Found",30,35,"","blue");
- bstr(".",50,"Using stored Data.");
- sleep(1);
- $outpage = $data;
- if ($loaded==1) {return();}
- $loaded=1;
- }
- $hpdzen = 0;
- $payouts = 0;
- $hpout = 0;
- $hp = 0;
- $hpup = 0;
- $hpdown = 0;
- $hpay = 0;
- $pay = 0;
- $fees = 0;
- $numfee = 0;
- $sval = '0';
- $pur = 0;
- $hppur = 0;
- $btcpur = 0;
- $usdpur = 0;
- $wdraw = 0;
- $btcwd = 0;
- $xfers = 0;
- $btcin = 0;
- $hsold = 0;
- $valsold = 0;
- $btcsold = 0;
- $recmia = 0;
- $profit = 0;
- $c = index($outpage, '"_id":"');
- $c = $c+7;
- $e = index($outpage, '","email"');
- $uid = substr($outpage,$c,$e-$c);
- if ($zenapi ne 'NO')
- {
- open(OUTFILE, ">$zenapi");
- print OUTFILE "$outpage";
- close(OUTFILE);
- }
- my @values = split('"createdAt":"', $outpage);
- my @payout = '';
- $a=0;
- open (PO, ">",$pof) or die $!;
- print PO "DATE,TIME,Miner Name,BTC PAY,Miner ID#,Transaction ID#\n";
- open (FEE, ">",$chf) or die $!;
- print FEE "DATE,TIME,Miner Name,Fee Amount,Transaction ID#\n";
- open (BUY, ">",$zpf) or die $!;
- print BUY "DATE,TIME,BTC Spent,HP Spent, USD Spent\n";
- open (HASH, ">",$hpf) or die $!;
- print HASH "DATE,TIME,HP + or -,Hashpoint Trigger\n";
- open (DEP, ">",$zdf) or die $!;
- print DEP "DATE,TIME,BTC Amount,Transaction ID#\n";
- open (WDR, ">",$zwf) or die $!;
- print WDR "DATE,TIME,BTC Amount,Transaction ID#\n";
- open (HSL, ">",$zsf) or die $!;
- print HSL "DATE,TIME,USD Amount\n";
- open (MIA, ">","zs_mia.txt") or die $!;
- print MIA "This is a record of unaccounted data during Zenscraper\n";
- print MIA "\n";
- foreach my $val (@values)
- {
- $c = 0;
- $e = index($values[$a], 'Z",');
- $sval = substr($values[$a],$c,$e-$c);
- my @dt = split(/T/,$sval);
- if (index($values[$a],']},"_id":"') !=-1)
- {
- $c = index($values[$a], ']},"_id":"');
- $c = $c+10;
- }
- elsif (index($values[$a],'"zpTransaction":"') !=-1)
- {
- $c = index($values[$a], '"zpTransaction":"');
- $c = $c+17;
- }
- else
- {
- $c = index($values[$a], '"transaction":"');
- $c = $c+15;
- }
- my $tid = substr($values[$a],$c,24);
- if ((index($values[$a], 'action":"device payout') != -1) && (index($values[$a], 'btcPayout') != -1))
- {
- $c = index($values[$a], 'btcPayout":"');
- $e = index($values[$a], ' BTC');
- $c = $c+12;
- my $amnt = substr($values[$a],$c,$e-$c);
- $pay = $pay + $amnt;
- $c = index($values[$a], '"name":"');
- $e = index($values[$a], '","coinType');
- $c = $c+8;
- my $mname = substr($values[$a],$c,$e-$c);
- if ((index($values[$a], 'hpPayout":"') != -1) && (index($values[$a], 'hpPayout":null') == -1))
- {
- $c = index($values[$a], 'hpPayout":"');
- $e = index($values[$a], ' HP');
- $c = $c+11;
- my $hpamnt = substr($values[$a],$c,$e-$c);
- if ($hpamnt>0)
- {
- $hpay = $hpay + $hpamnt;
- ++$hpout;
- print HASH $dt[0],",",$dt[1],",",$hpamnt,",","$mname - HashPool","\n";
- }
- }
- $c = index($values[$a], 'fee":"');
- $e = index($values[$a], ' BTC',$c);
- $c = $c+7;
- my $tfee = substr($values[$a],$c,$e-$c);
- if ($tfee eq '') {$tfee='0.0';}
- print PO $dt[0],",",$dt[1],",",$mname,",",$amnt,",N/A,",$tid,"\n";
- print FEE $dt[0],",",$dt[1],",",$mname,",",$tfee,",",$tid,"\n";
- ++$payouts;
- }
- elsif ((index($values[$a], '"details":"received payout') != -1) && (index($values[$a], ' BTC"') != -1))
- {
- $c = index($values[$a], 'payout of ');
- $e = index($values[$a], ' BTC');
- $c = $c+10;
- my $amnt = substr($values[$a],$c,$e-$c);
- $pay = $pay + $amnt;
- $c = index($values[$a], '"name":"');
- my $f = index($values[$a], '","_id":"');
- if ($f < $c){$e = index($values[$a], '","_id":"', $f+9);}
- if ($f > $c) { $e = $f;}
- $c = $c+8;
- my $mname = substr($values[$a],$c,$e-$c);
- my $mineid = substr($values[$a],$e+9,24);
- print PO $dt[0],",",$dt[1],",",$mname,",",$amnt,",",$mineid,",",$tid,"\n";
- ++$payouts;
- }
- elsif ((index($values[$a], 'action":"doublehash"') != -1) && (index($values[$a], ' HashPoint') != -1))
- {
- $c = index($values[$a], ' at ');
- $e = index($values[$a], ' HP","');
- $c = $c+4;
- my $amnt = substr($values[$a],$c,$e-$c);
- $hpay = $hpay + $amnt;
- print HASH $dt[0],",",$dt[1],",",$amnt,",","DOUBLE HASH - PAYOUT","\n";
- ++$hpout;
- }
- elsif ((index($values[$a], '"details":"received device payout') != -1) && (index($values[$a], ' HashPoints"') != -1))
- {
- $c = index($values[$a], 'payout of ');
- $e = index($values[$a], ' HashPoints');
- $c = $c+10;
- my $amnt = substr($values[$a],$c,$e-$c);
- $hpay = $hpay + $amnt;
- print HASH $dt[0],",",$dt[1],",",$amnt,",","Device Payout - HashPool","\n";
- ++$hpout;
- }
- elsif ((index($values[$a], '"details":"account credited') != -1) && (index($values[$a], ' BTC"') != -1))
- {
- $c = index($values[$a], 'credited ');
- $e = index($values[$a], ' BTC');
- $c = $c+9;
- my $amnt = substr($values[$a],$c,$e-$c);
- $pay = $pay + $amnt;
- print PO $dt[0],",",$dt[1],",ACCOUNT CREDITED,",$amnt,",",",","\n";
- ++$payouts;
- }
- elsif ((index($values[$a], '"details":"account service') != -1) && (index($values[$a], ' BTC"') != -1))
- {
- if (index($values[$a], 'fee -') != -1) {$c = index($values[$a], 'fee -'); $c = $c+5;}
- elsif (index($values[$a], 'fee ') != -1) {$c = index($values[$a], 'fee '); $c = $c+4;}
- else
- {
- print MIA $values[$a],"\n\n";
- ++$recmia;
- }
- $e = index($values[$a], ' BTC');
- my $tfee = substr($values[$a],$c,$e-$c);
- if (index($values[$a], 'fee -') != -1) {$fees = $fees + $tfee} else {$fees = $fees - $tfee};
- print FEE $dt[0],",",$dt[1],",UNKNOWN,",$tfee,",",$tid,"\n";
- ++$numfee;
- }
- elsif ((index($values[$a], '"details":"received payout') != -1) && (index($values[$a], ' ZenPoints') != -1))
- {
- $c = index($values[$a], 'payout of ');
- $e = index($values[$a], ' ZenPoints');
- $c = $c+10;
- my $thash = substr($values[$a],$c,$e-$c);
- print HASH $dt[0],",",$dt[1],",",$thash,",","Interest on BTC - Balance","\n";
- $hp = $hp + $thash;
- ++$hpout;
- }
- elsif ((index($values[$a], '"details":"received payout') != -1) && (index($values[$a], ' HashPoints') != -1))
- {
- $c = index($values[$a], 'payout of ');
- $e = index($values[$a], ' HashPoints');
- $c = $c+10;
- my $thash = substr($values[$a],$c,$e-$c);
- print HASH $dt[0],",",$dt[1],",",$thash,",","Interest on BTC - Balance","\n";
- $hp = $hp + $thash;
- ++$hpout;
- }
- elsif ((index($values[$a], '"action":"purchased miner"') != -1) or (index($values[$a], 'Auto Purchased') != -1))
- {
- if ((index($values[$a], 'HashPoints') != -1) && (index($values[$a], 'BTC') != -1) && (index($values[$a], 'USD') != -1))
- {
- $c = index($values[$a], 'with -');
- $e = index($values[$a], ' HashPoints');
- $c = $c+6;
- my $hps = substr($values[$a],$c,$e-$c);
- print HASH $dt[0],",",$dt[1],",",-$hps,",","Hashpoints spent on Zencloud purchase.","\n";
- $hppur = $hppur + $hps;
- $c = index($values[$a], 'HashPoints, -');
- $e = index($values[$a], ' BTC');
- $c = $c+13;
- $sval = substr($values[$a],$c,$e-$c);
- $btcpur = $btcpur + $sval;
- $c = index($values[$a], 'and $-');
- $e = index($values[$a], ' USD');
- $c = $c+6;
- my $usdval = substr($values[$a],$c,$e-$c);
- $usdpur = $usdpur + $usdval;
- print BUY $dt[0],",",$dt[1],",",$sval,",",$hps,",",$usdval,"\n";
- }
- elsif ((index($values[$a], 'HashPoints') != -1) && (index($values[$a], 'BTC') != -1) && (index($values[$a], 'USD') == -1))
- {
- $c = index($values[$a], 'with -');
- $e = index($values[$a], ' HashPoints');
- $c = $c+6;
- my $hps = substr($values[$a],$c,$e-$c);
- print HASH $dt[0],",",$dt[1],",",-$hps,",","Hashpoints spent on Zencloud purchase.","\n";
- $hppur = $hppur + $hps;
- $c = index($values[$a], 'and -');
- $e = index($values[$a], ' BTC');
- $c = $c+5;
- $sval = substr($values[$a],$c,$e-$c);
- $btcpur = $btcpur + $sval;
- print BUY $dt[0],",",$dt[1],",",$sval,",",$hps,"\n";
- }
- elsif ((index($values[$a], 'ZenPoints') != -1) && (index($values[$a], 'BTC') != -1))
- {
- $c = index($values[$a], 'with -');
- $e = index($values[$a], ' ZenPoints');
- $c = $c+6;
- my $hps = substr($values[$a],$c,$e-$c);
- print HASH $dt[0],",",$dt[1],",",-$hps,",","Hashpoints spent on Zencloud purchase.","\n";
- $hppur = $hppur + $hps;
- $c = index($values[$a], 'and -');
- $e = index($values[$a], ' BTC');
- $c = $c+5;
- $sval = substr($values[$a],$c,$e-$c);
- $btcpur = $btcpur + $sval;
- print BUY $dt[0],",",$dt[1],",",$sval,",",$hps,"\n";
- }
- elsif ((index($values[$a], 'HashPoints') != -1) && (index($values[$a], 'BTC') == -1))
- {
- $c = index($values[$a], 'with -');
- $e = index($values[$a], ' HashPoints');
- $c = $c+6;
- $sval = substr($values[$a],$c,$e-$c);
- $hppur = $hppur + $sval;
- print HASH $dt[0],",",$dt[1],",",-$sval,",","Hashpoints spent on Zencloud purchase.","\n";
- print BUY $dt[0],",",$dt[1],",0,",$sval,",0\n";
- }
- elsif ((index($values[$a], 'ZenPoints') != -1) && (index($values[$a], 'BTC') == -1))
- {
- $c = index($values[$a], 'with -');
- $e = index($values[$a], ' ZenPoints');
- $c = $c+6;
- $sval = substr($values[$a],$c,$e-$c);
- $hppur = $hppur + $sval;
- print HASH $dt[0],",",$dt[1],",",-$sval,",","Hashpoints spent on Zencloud purchase.","\n";
- print BUY $dt[0],",",$dt[1],",0,",$sval,",0\n";
- }
- elsif ((index($values[$a], 'HashPoints') == -1) && (index($values[$a], 'ZenPoints') == -1) && (index($values[$a], 'BTC') != -1))
- {
- $c = index($values[$a], 'with -');
- $e = index($values[$a], ' BTC');
- $c = $c+6;
- $sval = substr($values[$a],$c,$e-$c);
- $btcpur = $btcpur + $sval;
- print BUY $dt[0],",",$dt[1],",",$sval,"\n";
- }
- elsif ((index($values[$a], 'HashPoints') == -1) && (index($values[$a], 'ZenPoints') == -1) && (index($values[$a], 'BTC') == -1) && (index($values[$a], 'for $') != -1))
- {
- $c = index($values[$a], 'for $');
- $e = index($values[$a], '","user"');
- $c = $c+5;
- $sval = substr($values[$a],$c,$e-$c);
- $usdpur = $usdpur + $sval;
- print BUY $dt[0],",",$dt[1],",,,",$sval,"\n";
- }
- else
- {
- print MIA $values[$a],"\n\n";
- ++$recmia;
- }
- ++$pur;
- }
- elsif (index($values[$a], 'sold miner') != -1)
- {
- $c = index($values[$a], 'for $');
- $e = index($values[$a], 'user');
- $e = $e - 3;
- $c = $c+5;
- $sval = substr($values[$a],$c,$e-$c);
- $valsold = $valsold+$sval;
- print HSL $dt[0],",",$dt[1],",",$sval,"\n";
- ++$hsold;
- }
- elsif ((index($values[$a], '"details":"account credited 1 HashPoint') != -1))
- {
- print HASH $dt[0],",",$dt[1],",","1",",","Credited 1 HashPoint for Helpful Hashtalk","\n";
- ++ $hpup;
- }
- elsif ((index($values[$a], '"action":"hashtalk downvote') != -1))
- {
- print HASH $dt[0],",",$dt[1],",","-1",",","Deducted 1 HashPoint for hashtalk downvote","\n";
- ++ $hpdown;
- }
- elsif ((index($values[$a], '"action":"withdrawal') != -1))
- {
- $c = index($values[$a], 'for -');
- $e = index($values[$a], ' BTC');
- $c = $c+5;
- $sval = substr($values[$a],$c,$e-$c);
- $btcwd = $btcwd + $sval;
- print WDR $dt[0],",",$dt[1],",",$sval,",",$tid,"\n";
- ++ $wdraw;
- }
- elsif ((index($values[$a], '"action":"transfer completed') != -1))
- {
- $c = index($values[$a], 'for ');
- $e = index($values[$a], ' BTC');
- $c = $c+4;
- $sval = substr($values[$a],$c,$e-$c);
- $btcin = $btcin + $sval;
- print DEP $dt[0],",",$dt[1],",",$sval,",",$tid,"\n";
- ++ $xfers;
- }
- elsif ((index($values[$a], '"account HashPoints debit"') != -1))
- {
- $c = index($values[$a], 'debited -');
- $e = index($values[$a], ' HashPoints","');
- $c = $c+9;
- $sval = substr($values[$a],$c,$e-$c);
- print HASH $dt[0],",",$dt[1],",","-",$sval,",","Account Deducted $sval HashPoints","\n";
- $hpdzen = $hpdzen + $sval;
- }
- elsif ((index($values[$a], '"action":"transfer') == -1) && (index($values[$a], '"details":"Merged') == -1) && (index($values[$a], 'code was activated') == -1) && (index($values[$a], '"iTotalRecords":') == -1) && (index($values[$a], 'changed miner name') == -1) && (index($values[$a], '"details":"Received') == -1) && (index($values[$a], '"action":"signup"') == -1) && (index($values[$a], '"action":"profile"') == -1) && (index($values[$a], '"details":"Split') == -1) && (index($values[$a], '"details":"Upgraded') == -1))
- {
- print MIA $values[$a],"\n\n";
- ++$recmia;
- }
- ++$a;
- }
- $profit = $pay - $fees;
- close PO;
- sortcsv($pof);
- close FEE;
- sortcsv($chf);
- close BUY;
- sortcsv($zpf);
- close HASH;
- sortcsv($hpf);
- close DEP;
- sortcsv($zdf);
- close WDR;
- sortcsv($zwf);
- close HSL;
- sortcsv($zsf);
- close MIA;
- if ($hsold > 0)
- {
- my $finurl = "https://cloud.zenminer.com/api/dt/financials?iDisplayLength=0";
- $mech->get($finurl);
- my $findat = Dumper ($mech->content());
- $e = 0;
- foreach my $i (1..$hsold)
- {
- $c = index($findat, 'Sale', $e);
- $e = index($findat, ' BTC', $c);
- $c = $c+51;
- $sval = substr($findat,$c,$e-$c);
- $btcsold = $btcsold+$sval;
- }
- }
- }
- else {zencon();}
- }
- sub main
- {
- clrscr();
- bcol("blue");
- tcol("");
- fstr(" ",75,"ZENscrape $ver by Cryptichermit");
- rstr(" ",45);
- bcol("green");
- tcol("black");
- rstr(" ",2);
- bstr(" ",38,"BTC value - $btcval USD");
- fstr(" ",80,"Balances - $btdash BTC $usdash USD $hpdash HP ");
- bcol("");
- cpos(4,5);
- tcol("purple");
- bcol("black");
- bstr(" ",15,"Payout Info:");
- fstr(" ",35,"Number of Payouts: $payouts");
- cpos(5,5);
- rstr("=",50);
- tcol("cyan");
- cpos(6,5);
- print "Total Payout:";
- fstr(".",16,sprintf("%.8f",$pay));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$pay*$btcval));
- print " USD";
- cpos(7,5);
- print "Total Profit:";
- fstr(".",16,sprintf("%.8f",$profit));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$profit*$btcval));
- print " USD";
- cpos(4,65);
- tcol("purple");
- bstr(" ",12,"Fee Info:");
- fstr(" ",38,"Number of Fee Records: $numfee");
- cpos(5,65);
- rstr("=",50);
- tcol("cyan");
- cpos(6,65);
- print "Total Fees:";
- fstr(".",18,sprintf("%.8f",$fees));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$fees*$btcval));
- print " USD";
- cpos(7,65);
- bstr(".",20,"Your Fees account for");
- fstr(".",10,sprintf("%.2f",$fees/$pay*100));
- print ".%.....of BTC mined";
- cpos(9,5);
- tcol("purple");
- bstr(" ",15,"Purchase Info:");
- fstr(" ",35,"Number of ZENcloud Purchases: $pur");
- cpos(10,5);
- rstr("=",50);
- tcol("cyan");
- cpos(11,5);
- bstr(".",13,"BTC Spent:");
- fstr(".",16,sprintf("%.8f",$btcpur));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$btcpur*$btcval));
- print " USD";
- cpos(12,5);
- bstr(".",13,"USD Spent:");
- fstr(".",33,$usdpur);
- print " USD";
- cpos(13,5);
- bstr(".",20,"HashPoints Spent:");
- fstr(".",26,$hppur);
- print " HP ";
- cpos(9,65);
- tcol("purple");
- bstr(" ",15,"Transfer Info:");
- fstr(" ",35,"Number of Withdrawals: $wdraw");
- cpos(10,65);
- fstr(" ",50,"Number of Deposits: $xfers");
- cpos(11,65);
- rstr("=",50);
- cpos(12,65);
- tcol("cyan");
- bstr(".",13,"BTC Withdrawn:");
- fstr(".",15,sprintf("%.8f",$btcwd));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$btcwd*$btcval));
- print " USD";
- cpos(13,65);
- bstr(".",13,"BTC Deposited:");
- fstr(".",15,sprintf("%.8f",$btcin));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$btcin*$btcval));
- print " USD";
- cpos(15,5);
- tcol("purple");
- bstr(" ",15,"Sales Info:");
- fstr(" ",35,"Number of Miners Sold: $hsold");
- cpos(16,5);
- rstr("=",50);
- tcol("cyan");
- cpos(17,5);
- bstr(".",13,"BTC Earned:");
- fstr(".",16,sprintf("%.8f",$btcsold));
- print " BTC";
- fstr(".",13,sprintf("%.2f",$valsold));
- print " USD";
- cpos(18,5);
- rstr(" ",50);
- cpos(19,5);
- rstr(" ",50);
- cpos(20,5);
- rstr(" ",50);
- cpos(21,5);
- rstr(" ",50);
- cpos(15,65);
- tcol("purple");
- bstr(" ",16,"HashPoints Info:");
- fstr(" ",34,"HP Payouts: $hpout");
- cpos(16,65);
- rstr("=",50);
- tcol("cyan");
- cpos(17,65);
- bstr(".",32,"HashPoints Earned from Interest:");
- fstr(".",18,"$hp HP");
- cpos(18,65);
- bstr(".",32,"HashPoints Earned from UP votes:");
- fstr(".",18,"$hpup HP");
- cpos(19,65);
- bstr(".",36,"HashPoints deducted from Down votes:");
- fstr(".",14,"$hpdown HP");
- cpos(20,65);
- bstr(".",36,"HashPoints deducted by ZENcloud:");
- fstr(".",14,"$hpdzen HP");
- cpos(21,65);
- bstr(".",36,"HashPoints Earned Mining HashPool:");
- fstr(".",14,"$hpay HP");
- tcol("black");
- bcol("green");
- cpos(38,0);
- rstr(" ",120);
- cpos(39,0);
- rstr(" ",120);
- cpos(40,0);
- rstr(" ",120);
- cpos(38,110);
- print "(Timers)";
- cpos(39,107);
- print "BTC";
- cpos(39,112);
- print "DASH";
- cpos(39,117);
- print "REC";
- cpos(40,113);
- fstr(" ",1,$dashtime-$dashval);
- cpos(40,118);
- fstr(" ",1,$rectime-$recval);
- cpos(38,1);
- print "(A)ll data to XLS - (B)uild daily Charts - (C)hart history - (G)roup Miner Menu - (M)iner Menu";
- cpos(39,1);
- print "(R)OI - (T)oday XLS - BTC (V)alue history - e(X)it ZENscrape";
- ReadMode(4);
- for (my $x = 0; $x < 20; $x++) {
- if (defined ($key = ReadKey(-1)))
- {
- if ($key eq 'x')
- {
- clrscr();
- tcol("white");
- bcol("black");
- print "Thank you for using ZENscrape $ver \n\n";
- ReadMode(1);
- undef $mech;
- exit;
- }
- if ($key eq 'a')
- {
- createxls();
- if ($ssoft eq 'LO') {system("libreoffice -o ZEN.xls > /dev/null &");main();}
- if ($ssoft eq 'MO') {system("ZEN.xls");main();}
- }
- if ($key eq 't')
- {
- gdate();
- tdayxls();
- if ($ssoft eq 'LO') {system("libreoffice -o ZEN_$rdate.xls > /dev/null &");main();}
- if ($ssoft eq 'MO') {system("ZEN_$rdate.xls");main();}
- }
- if ($key eq 'b')
- {
- dbox(50,"Creating ALL daily charts XLS",30,35,"","blue");
- bstr(".",45,"Creating Daily Chart");
- bdayxls();
- }
- if ($key eq 'c')
- {
- dbox(50,"Creating Historical Chart",30,35,"","blue");
- bstr(".",50,"Creating Chart");
- chartxls();
- cpos(32,81);
- print "DONE";
- sleep(1);
- if ($ssoft eq 'LO') {system("libreoffice -o ZEN_chart.xls > /dev/null &");main();}
- if ($ssoft eq 'MO') {system("ZEN_chart.xls");main();}
- }
- if ($key eq 'g')
- {
- dbox(50,"Group Miner Menu",30,35,"","red");
- bstr(".",49,"Sorry, this will be a future feature");
- foreach my $i (1..3)
- {
- print 4-$i;
- sleep(1);
- cpos(32,84);
- }
- }
- if ($key eq 'm')
- {
- dbox(50,"Miner Menu",30,35,"","red");
- bstr(".",49,"Sorry, this will be a future feature");
- foreach my $i (1..3)
- {
- print 4-$i;
- sleep(1);
- cpos(32,84);
- }
- }
- if ($key eq 'r')
- {
- dbox(50,"ROI Menu",30,35,"","red");
- bstr(".",49,"Sorry, this will be a future feature");
- foreach my $i (1..3)
- {
- print 4-$i;
- sleep(1);
- cpos(32,84);
- }
- }
- if ($key eq 'v')
- {
- dbox(50,"Historical BTC Value",30,35,"","red");
- bstr(".",49,"Sorry, this will be a future feature");
- foreach my $i (1..3)
- {
- print 4-$i;
- sleep(1);
- cpos(32,84);
- }
- }
- $x=20;
- }
- cpos(40,108);
- tcol("black");
- bcol("green");
- fstr(" ",2,20-$x);
- cpos(0,0);
- sleep(1);
- }
- ++$recval;
- ++$dashval;
- btcv();
- if ($dashval==$dashtime){ dash(); $dashval=0;}
- if ($recval==$rectime){ crec(); $recval=0;}
- main();
- }
- clrscr();
- printf("\e[8;40;120;t");
- tcol("");
- bcol("blue");
- rstr(" ",40);
- print "Welcome to ZENscrape $ver by Cryptichermit";
- rstr(" ",80-length("Welcome to ZENscrape $ver by Cryptichermit"));
- bcol("");
- if (-e $zenapi) {
- open my $fh, '<', $zenapi or die "error opening $zenapi: $!";
- $data = do { local $/; <$fh> };
- $c = index($data, '"iTotalRecords":');
- $c = $c+16;
- $e = index($data, ',"aaData"');
- $locrec = substr($data,$c,$e-$c);
- print "($zenapi - Found) - Welcome Back!\nLast recorded record = $locrec - loading local data\n\n";
- close $fh;
- $c = index($data, '[{"createdAt"');
- $sdata = substr($data,$c);
- }
- if ($btcval == 0)
- {
- btcv();
- }
- crec();
- dash();
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement