PDAScraper/Template.pm untested

filter: Statementstmt 0.0% 0 / 5 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 7 CC 1 SCAR 6.9
CC
1
Cov
0%
config
2.0
CRAP 2.0
1 package WWW::PDAScraper::Foo;
2  
3 # PDAScraper.pm rules for scraping the
4 # Foo website
5  
6 sub config {
7 return {
8 name => 'Foo',
9 # Name of the website. Arbitrary text.
10  
11 start_from => 'http://www.foo.com/news/',
12 # URL where the scraper should find the links.
13  
14 url_regex => [ '$', '&print=1' ],
15 # This is the simple form of the url_regex, which
16 # is used to change a regular link to a "print-friendly"
17 # link. Simple because there are no backreferences
18 # neede on the RHS.
19  
20 # url_regex => [
21 # '/id/(\d+)/',
22 # sub { \ "/toolbar.aspx?action=print&id=$1" }
23 # ],
24 # This is the complex form of the url_regex, using
25 # a sub to return because it needs to evaluate a
26 # backreference i.e. $1, $2 etc.
27  
28 chunk_spec => [ "_tag", "div", "id", "headlines" ],
29 # A list of arguments to HTML::Element's look_down()
30 # method. The example will return an HTML::Element
31 # objectmatching the first ID tag having the
32 # attribute"id" with value "headlines".
33  
34 # If you can't use a chunk_spec, you'll have to use a
35 # chunk_regex:
36  
37 # chunk_regex => qr{<table border="0" width="512">(.*?)</table>}s,
38 # A regular expression which returns your desired
39 # chunk of the page as $1. Using chunk_spec is better.
40
41 link_spec => [sub { $_[0]->as_text ne 'FULL STORY' }],
42 # All links are grabbed from the page chunk by default,
43 # but chunk_spec allows you to add HTML::Element
44 # filtering, here, for example, rejecting links in the
45 # form <a href="foo">FULL STORY</a>, but you could also
46 # reject them on any attribute, see HTML::Element.
47
48 # encoding => 'iso-8859-1'
49 # optional, if you need to specify the encoding of the
50 # page, so that special characters appear correctly.
51 # defaults to UTF-8 if you don't have one
52  
53 };
54 }
55  
56 1;
57