Here's a basic example using Mojo::UserAgent:
use feature 'say'; use Mojo::UserAgent; my $ua = Mojo::UserAgent->new; my $coinbaseURL = 'https://api.coindesk.com/v1/bpi/currentprice/usd.js +on'; my $value = $ua->get( $coinbaseURL )->result->json->{bpi}{USD}{rate}; say "Bitcoin Price (USD): $value";
If I were doing such a thing I'd likely just use Mojolicious::Lite for the site/page, and create a little route based on the example above (throw in some error checking etc) to return this as json, and call that route on the page every few minutes via JavaScript, so that the Bitcoin price updated without having to refresh/reload the page, from expedience tends to be how users expect things to work these days. See also Mojolicious -> Tutorial and UserAgent.
In reply to Re: bitcoin price from command line
by marto
in thread bitcoin price from command line
by *alexandre*
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |