File: 09-process_hash.t

package info (click to toggle)
libweb-scraper-perl 0.38-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 308 kB
  • sloc: perl: 473; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 631 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use strict;
use Test::Base;

use Web::Scraper;
plan tests => 1 * blocks;

filters {
    selector => 'chomp',
    args     => 'yaml',
    expected => 'yaml',
};

run {
    my $block = shift;
    my $s = scraper {
        process $block->selector, @{ $block->args };
    };
    my $data = $s->scrape($block->html);
    is_deeply $data, $block->expected, $block->name;
};

__DATA__

===
--- html
<ul>
<li><a href="foo.html">foo</a></li>
<li><a href="bar.html">bar</a></li>
</ul>
--- selector
ul>li>a
--- args
- sites[]
- link: '@href'
  name: TEXT
--- expected
sites:
  - link: foo.html
    name: foo
  - link: bar.html
    name: bar