pastebin

Paste #82320: Untitled Perl paste by 203.114.244.88

#!/usr/bin/perl 
  
use strict;  
use warnings;  
use JSON qw(decode_json);  
use LWP::UserAgent;
use utf8;
#no warnings 'utf8';  

my $ua = LWP::UserAgent->new;  
my $response = $ua->get('http://douban.fm');  
my %type = $response->content =~  
    /<li data-genre_id="(\d+?)">(.+?)<\/li>/g;  
foreach (keys %type) {  
    print "$_ = $type{$_}\n";  
}  
binmode(STDOUT, ':encoding(utf8)');
  
my $channels_url =  
    'http://douban.fm/j/explore/search?query=genre_id:'  
    .'335'  
    .'&start=0&limit=20';  
$response = $ua->get($channels_url);  
my $json = decode_json($response->content);  
foreach (@{$json->{data}{channels}}) {  
    print $_->{name}."\n";  
}

Private
Wrap long lines

2 + 5 =