TaskPipe/Template_Task_SP500ScrapeCompanies.pm

filter: Statementstmt 100% 7 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 8 / 8 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« TaskPipe/Template_Plan_Stub.pm ↑ Summary TaskPipe/Template_Task_SP500ScrapeQuote.pm »
1 package TaskPipe::Template_Task_SP500ScrapeCompanies;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 extends 'TaskPipe::Template_Task';
5  
6 1 has name => (is => 'ro', isa => 'Str', default => 'Scrape_Companies');
7 1 has template => (is => 'ro', isa => 'Str', default =>
8  
9 q|##################################################################
10 #
11 # Sample task:
12 # Scrape List of S&P500 Companies from Wikipedia
13 #
14 ##################################################################
15  
16 package <% task_module_prefix %>::<% task_identifier %><% name %>;
17  
18 use Moose;
19 use Web::Scraper;
20 extends 'TaskPipe::Task_Scrape';
21  
22  
23 has test_pinterp => (is => 'ro', isa => 'ArrayRef[HashRef]', default => sub{[
24  
25 {
26 url => 'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies',
27 headers => {
28 Referer => 'https://www.google.com'
29 }
30 }
31  
32 ]});
33  
34  
35 has ws => (is => 'ro', isa => 'Web::Scraper', default => sub {
36 scraper {
37 process_first 'table.wikitable', 'table' => scraper {
38 process 'tr + tr', 'tr[]' => scraper {
39 process_first 'td:nth-child(1) a', 'ticker' => 'TEXT';
40 process_first 'td:nth-child(1) a', 'url' => ['@href',sub{ $_[0]->as_string }];
41 process_first 'td:nth-child(2) a', 'name' => 'TEXT';
42 process_first 'td:nth-child(4)', 'sector' => 'TEXT';
43 process_first 'td:nth-child(5)', 'industry' => 'TEXT';
44 process_first 'td:nth-child(6)', 'address' => 'TEXT';
45 process_first 'td:nth-child(7)', 'date_added' => 'TEXT';
46 process_first 'td:nth-child(8)', 'cik' => 'TEXT';
47 };
48 result 'tr';
49 };
50 result 'table';
51 };
52 });
53  
54 1;|);
55  
56 =head1 NAME
57  
58 TaskPipe::Template_Task_SP500Scrape_Companies - template for the Scrape_Companies task in the SP500 sample project
59  
60 =head1 DESCRIPTION
61  
62 Template for the Scrape_Companies task in the SP500 sample project
63  
64 =head1 AUTHOR
65  
66 Tom Gracey <tomgracey@gmail.com>
67  
68 =head1 COPYRIGHT AND LICENSE
69  
70 Copyright (c) Tom Gracey 2018
71  
72 TaskPipe is free software, licensed under
73  
74 The GNU Public License Version 3
75  
76 =cut
77  
78  
79 1 1;
80  
81  
82
« TaskPipe/Template_Plan_Stub.pm ↑ Summary TaskPipe/Template_Task_SP500ScrapeQuote.pm »