| WWW-Hashdb documentation | Contained in the WWW-Hashdb distribution. |
WWW::Hashdb - search by http://hashdb.com/.
Version 0.01
use WWW::Hashdb;
use XXX;
my $hashdb = WWW::Hashdb->new( limit => 10 );
my @items = $hashdb->search("BURST CITY");
XXX @items;
none.
Tomohiro Hosaka, <bokutin at cpan.org>
Copyright 2008 Tomohiro Hosaka, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WWW-Hashdb documentation | Contained in the WWW-Hashdb distribution. |
package WWW::Hashdb; use warnings; use strict; use Moose; use Params::Validate; use WWW::Mechanize; use Web::Scraper;
our $VERSION = '0.01';
has 'limit' => ( is => 'rw', isa => 'Int', default => 10 );
sub search { my ($self, $word) = validate_pos(@_, 1, 1); # http://hashdb.com/search.php?q=SYMPHONY+X&p=1&s=u # q = query, words # p = page # s = ??? my @items; { my @pages = do { my $first = URI->new("http://hashdb.com/search.php"); $first->query_form( { q => $word, p => 1 } ); $first; }; #warn $uri->as_string; my $item = scraper { process "p.searchList"; process 'input', ignore => '@value'; }; my $lists = scraper { # <a href="search.php?q=aho&p=2&s=u" title="次ã®ãã¼ã¸ã¸" accesskey="N">次ã¸(<span class="underline">N</span>)</a> process 'a[accesskey="N"]', "next" => '@href'; process 'form[name="download"]>p', "items[]" => $item; #result 'items'; }; while (my $uri = shift @pages) { my $items_ref = $lists->scrape( $uri ); push @items, @{$items_ref->{items} || []}; last if $self->limit > 0 and @items >= $self->limit; push @pages, $items_ref->{next}; } } for my $item (@items) { my @parts = split(/,/, $item->{ignore}); # å é ã®ãã£ã¼ã«ããååãã«ã¯ã,ããããªãã¿ã¨ãã¦ã§ã¯ãªã表ããå ´åãããã until (@parts == 8) { $parts[0] = join(',', @parts[0 .. 1]); splice(@parts, 1, 1); } # ï¼ã¢ãã¡ï¼[ã©ã¹ãã¨ã°ã¶ã¤ã« LASTEXILE] (OP) Cloud Age Symphony.mp3,kzELjn4dD0,0,0,6d3d7136e9a7753108aa44e4a20526b7,0,1,0 $item->{name} = $parts[0]; $item->{trip} = $parts[1]; $item->{hash} = $parts[4]; $item->{fetch} = $item->{hash} ? join(",", "", "", 0, 0, $item->{hash}, 0) : undef; } return @items; }
1;