00_test_function_crawl.t 551 B

12345678910111213141516171819
  1. #!/usr/bin/env perl
  2. use Scrappy;
  3. use FindBin;
  4. use Test::More $ENV{TEST_LIVE} ?
  5. (tests => 1) : (skip_all => 'env var TEST_LIVE not set, live testing is not enabled');
  6. my $s = Scrappy->new;
  7. $s->crawl('http://search.cpan.org/recent',
  8. '/recent' => {
  9. '#cpansearch li a' => sub {
  10. defined $_[0]->stash->{links} ?
  11. push @{$_[0]->stash->{links}}, $_[1]->{href} :
  12. $_[0]->stash('links' => [$_[1]->{href}]);
  13. }
  14. }
  15. );
  16. ok scalar @{$s->stash->{links}} > 0;