Title: Quick PHP dev to parse out networkhashpersec ABE
Post by: sal002 on May 28, 2013, 10:26:41 PM
Trying to parse out, for a given coin, the networkhashpersec from here:
http://cnc.cryptocoinexplorer.com/chain/CHNCoin/q/nethash/1/-1
When I append format=json, I lose the hashrate. So, looking for someone to whip up a quick PHP script to parse the most recent nethash.
Title: Re: Quick PHP dev to parse out networkhashpersec ABE
Post by: nzbmaster on May 29, 2013, 12:31:40 AM
Here's a super quick take on your request. Call via url with ?coin=ftc for example or change $defaultCoin to the coin you want the last hashrate for. It's probably easier to ask the dev to include the data in the json output though... <?php
$defaultCoin = 'cnc';
$cryptoCurrencies = array( 'ppc'=>'PPCoin', 'trc'=>'Terracoin', 'frc'=>'Freicoin', 'bbq'=>'BBQCoin', 'nvc'=>'Novacoin', 'ftc'=>'Feathercoin', 'bte'=>'Bytecoin', 'btb'=>'BitBar', 'cnc'=>'CHNCoin', 'jkc'=>'JKC', 'frk'=>'Franko', 'gld'=>'Goldcoin' );
$baseUrl = 'http://%s.cryptocoinexplorer.com/chain/%s/q/nethash/1/-1';
$coin = (isset($_GET['coin']) && array_key_exists($_GET['coin'], $cryptoCurrencies)) ? $_GET['coin'] : $defaultCoin;
$url = sprintf($baseUrl, $coin, $cryptoCurrencies[$coin]); $rawdata = file_get_contents($url); if ($rawdata) { if (preg_match("/\n(?P<headers>[a-z,]+)\nSTART DATA\n(?P<data>.*?)\n/i", $rawdata, $matches)) { $headers = explode(',', $matches['headers']); $data = explode(',', $matches['data']); $result = array_combine($headers, $data); echo $result['netHashPerSecond'];
//print_r($result); } }
?>
Title: Re: Quick PHP dev to parse out networkhashpersec ABE
Post by: sal002 on May 29, 2013, 02:42:45 AM
Here's a super quick take on your request. Call via url with ?coin=ftc for example or change $defaultCoin to the coin you want the last hashrate for. It's probably easier to ask the dev to include the data in the json output though... <?php
$defaultCoin = 'cnc';
$cryptoCurrencies = array( 'ppc'=>'PPCoin', 'trc'=>'Terracoin', 'frc'=>'Freicoin', 'bbq'=>'BBQCoin', 'nvc'=>'Novacoin', 'ftc'=>'Feathercoin', 'bte'=>'Bytecoin', 'btb'=>'BitBar', 'cnc'=>'CHNCoin', 'jkc'=>'JKC', 'frk'=>'Franko', 'gld'=>'Goldcoin' );
$baseUrl = 'http://%s.cryptocoinexplorer.com/chain/%s/q/nethash/1/-1';
$coin = (isset($_GET['coin']) && array_key_exists($_GET['coin'], $cryptoCurrencies)) ? $_GET['coin'] : $defaultCoin;
$url = sprintf($baseUrl, $coin, $cryptoCurrencies[$coin]); $rawdata = file_get_contents($url); if ($rawdata) { if (preg_match("/\n(?P<headers>[a-z,]+)\nSTART DATA\n(?P<data>.*?)\n/i", $rawdata, $matches)) { $headers = explode(',', $matches['headers']); $data = explode(',', $matches['data']); $result = array_combine($headers, $data); echo $result['netHashPerSecond'];
//print_r($result); } }
?>
Thanks! Do you have an address to tip you?
Title: Re: Quick PHP dev to parse out networkhashpersec ABE
Post by: nzbmaster on May 29, 2013, 04:01:26 AM
If it was helpful feel free to tip me here 135ZDfQUQua5fwH9dwrX7n1Rkm9HzszrXy but don't feel obliged, I didn't spend very long on it.
Thanks.
|