Using my module HTTP::Request::FromCurl or it's associated online website, curl2lwp, you can conveniently convert any curl command to Perl.
#!perl use strict; use warnings; use WWW::Mechanize; use HTTP::Request; my $ua = WWW::Mechanize->new(); my $r = HTTP::Request->new( 'GET' => 'https://api.coindesk.com/v1/bpi/currentprice/usd.json', [ 'Accept' => '*/*', 'Host' => 'api.coindesk.com:443', 'User-Agent' => 'curl/7.55.1', ], ); my $res = $ua->request( $r, ); __END__ Created from curl command line curl -s https://api.coindesk.com/v1/bpi/currentprice/usd.json
Reading and extracting the rate from the JSON file is easiest done using the JSON module (or JSON::PP or JSON::XS or ...), which convert the JSON to a nice data structure which you can then traverse from Perl.
In reply to Re: bitcoin price from command line
by Corion
in thread bitcoin price from command line
by *alexandre*
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |