2 # SCRIPTNAME DOES_SOMETHING
3 # and is released under the terms of the GNU GPL version 3, or any
4 # later version, at your option. See the file README and COPYING for
6 # Copyright 2016 by Don Armstrong <don@donarmstrong.com>.
17 SCRIPTNAME - DOES_SOMETHING
24 --debug, -d debugging level (Default 0)
25 --help, -h display this help
26 --man, -m display manual
34 Debug verbosity. (Default 0)
38 Display brief usage information.
54 use WWW::Mechanize::TreeBuilder;
58 tie my $uuid, 'OSSP::uuid::tie';
61 my %options = (debug => 0,
71 'debug|d+','help|h|?','man|m');
73 pod2usage() if $options{help};
74 pod2usage({verbose=>2}) if $options{man};
76 $DEBUG = $options{debug};
80 # push @USAGE_ERRORS,"You must pass something";
83 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
86 (herc => {url => 'http://main.hercjobs.org/jobs/search?keywords=professor+AND+%28genomics+OR+bioinformatics+OR+biology+OR+informatics%29&discipline=academic-faculty&category=academic-faculty&category=allied-health&category=biological-biomedical-sciences&category=computer-information-sciences&category=education&category=interdisciplinary&category=mathematics-statistics&category=medical-research&category=physical-sciences&sort=DATE_POSTED+DESC',
87 next_selector => [class => "bti-pagination-previous-link bti-pagination-prev-next"],
88 job_selector => [url_regex => qr{^\/jobs\/\d+/.+}],
89 university => [itemprop=>"hiringOrganization",itemtype=>"http://schema.org/Organization"],
90 description => [class=>"bti-jd-description",itemprop=>"description"],
91 date => [class=>"bti-jd-detail-text",
92 sub {scalar $_[0]->parent()->attr('class') eq 'bti-jd-details-action'}],
93 position => [class=>"bti-jd-title",itemprop=>"title"],
97 binmode STDOUT,":utf8";
98 get_jobs($options{site},$options{pages});
100 my ($site,$pages) = @_;
102 my $m = WWW::Mechanize->new();
103 WWW::Mechanize::TreeBuilder->meta->apply($m);
104 if (not defined $sites{$site}) {
105 die "Unknown site $site";
107 my $s = $sites{$site};
111 my @job_urls = grep { ! $seen{ $_->URI()->abs() }++ }
112 $m->find_all_links(@{$s->{job_selector}});
113 for my $j_u (@job_urls) {
115 my $university = $m->tree->look_down(@{$s->{university}})->as_text();
116 my $date = $m->tree->look_down(@{$s->{date}})->as_text();
117 my $description = $m->tree->look_down(@{$s->{description}})->as_text();
118 my $position = $m->tree->look_down(@{$s->{position}})->as_text();
119 print format_job($university,$position,$j_u->URI->abs(),$description,$date);
122 $m->follow_link(@{$s->{next_selector}});
127 my ($university,$position,$url,$text,$date) = @_;
128 $text =~ s/(\n)(\s*)/$1 /m;
130 ** TODO $university -- $position