Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: cpanr - view cpan ratings from the command line ( ojo::g )

by beech (Parson)
on Oct 05, 2016 at 23:45 UTC ( #1173369=note: print w/replies, xml ) Need Help??


in reply to cpanr - view cpan ratings from the command line

Hi,

use Mojo::DOM and WWW::Mechanize?

:D

... use ojo; # use Mojo::DOM; # use WWW::Mechanize; ... # my $mech = WWW::Mechanize->new(); # $mech->get($ratingsURL); # # my $dom = Mojo::DOM->new($mech->content()); my $dom = g( $ratingsURL )->dom;

https://metacpan.org/pod/ojo#g

update: it didn't work for ojo, so to make that work, fetch the distribution name instead of guessing it

# $module =~ s/::/-/g; $module = g('http://api.metacpan.org/v0/module/'.$module)->json->{ +distribution};

ref https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md, https://metacpan.org/pod/Mojo::Message#json

Replies are listed 'Best First'.
Re^2: cpanr - view cpan ratings from the command line ( ojo::g )
by marto (Archbishop) on Oct 06, 2016 at 09:22 UTC

    Fantastic feedback, thanks. I was unaware of ojo. I'll definitely look at using this going forward.

      You probably realized already but itís to facilitate one-liners. And it actually led me to find what I believe to be a bug in the text handing of Mojo. In my view, all_text and text should find the alt info in images. In this case it would have shown the star ratings which would have been a nice DWIW. :P

      perl -Mojo -E 'say $_->all_text, $/ for g("http://cpanratings.perl.org +/dist/" . +shift=~s/::/-/r)->dom->find(".review")->each' CGI perl -Mojo -E 'say $_->all_text, $/ for g("http://cpanratings.perl.org +/dist/" . +shift=~s/::/-/r)->dom->find(".review")->each' Mojolicious

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1173369]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2019-07-22 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (17 votes). Check out past polls.

    Notices?