Bitcoin Forum
April 25, 2024, 12:41:29 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Quick PHP dev to parse out networkhashpersec ABE  (Read 926 times)
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 28, 2013, 10:26:41 PM
 #1

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.
"If you don't want people to know you're a scumbag then don't be a scumbag." -- margaritahuyan
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714048889
Hero Member
*
Offline Offline

Posts: 1714048889

View Profile Personal Message (Offline)

Ignore
1714048889
Reply with quote  #2

1714048889
Report to moderator
1714048889
Hero Member
*
Offline Offline

Posts: 1714048889

View Profile Personal Message (Offline)

Ignore
1714048889
Reply with quote  #2

1714048889
Report to moderator
1714048889
Hero Member
*
Offline Offline

Posts: 1714048889

View Profile Personal Message (Offline)

Ignore
1714048889
Reply with quote  #2

1714048889
Report to moderator
nzbmaster
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
May 29, 2013, 12:31:40 AM
 #2

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...

Code:
<?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);
}
}

?>

sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 29, 2013, 02:42:45 AM
 #3

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...

Code:
<?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?
nzbmaster
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
May 29, 2013, 04:01:26 AM
 #4

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!