in reply to bitcoin price from command line
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: bitcoin price from command line
by *alexandre* (Scribe) on Jan 08, 2019 at 11:38 UTC | |
by Corion (Patriarch) on Jan 08, 2019 at 12:20 UTC |