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 use POSIX qw(strftime);
60 tie my $uuid, 'OSSP::uuid::tie';
63 my %options = (debug => 0,
73 'debug|d+','help|h|?','man|m');
75 pod2usage() if $options{help};
76 pod2usage({verbose=>2}) if $options{man};
78 $DEBUG = $options{debug};
82 # push @USAGE_ERRORS,"You must pass something";
85 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
88 (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',
89 next_selector => [class => "bti-pagination-previous-link bti-pagination-prev-next",text => '>'],
90 job_selector => [url_regex => qr{^\/jobs\/\d+/.+}],
91 university => [itemprop=>"hiringOrganization",itemtype=>"http://schema.org/Organization"],
92 description => [class=>"bti-jd-description",itemprop=>"description"],
93 date => [class=>"bti-jd-detail-text",
94 sub {scalar $_[0]->parent()->attr('class') eq 'bti-jd-details-action'}],
95 position => [class=>"bti-jd-title",itemprop=>"title"],
97 nature => {url => 'http://www.nature.com/naturejobs/science/jobs?utf8=%E2%9C%93&q%5B%5D=professor&job_type%5B%5D=Assistant+Professor&job_type%5B%5D=Professor&order_by=created_on',
98 next_selector => [class=>"next_page",url_regex=>qr{^/naturejobs/science/jobs},],
99 job_selector => [url_regex => qr{^/naturejobs/science/jobs/\d+-.+}],
100 university => [href => qr{^/naturejobs/science/employer-directory/\d+$}],
101 description => [class=>"job-description"],
103 position => [class=>'job-title heading'],
107 binmode STDOUT,":utf8";
108 get_jobs($options{site},$options{pages});
111 my ($site,$pages) = @_;
113 my $todays_date = strftime('%Y-%m-%d %H:%M:%S',localtime());
115 my $m = WWW::Mechanize->new();
116 WWW::Mechanize::TreeBuilder->meta->apply($m);
117 if (not defined $sites{$site}) {
118 die "Unknown site $site";
120 my $s = $sites{$site};
124 my @job_urls = grep { ! $seen{ $_->URI()->abs() }++ }
125 $m->find_all_links(@{$s->{job_selector}});
126 for my $j_u (@job_urls) {
128 my $university = 'No university';
130 $university = $m->tree->look_down(@{$s->{university}})->as_text();
132 my $date = $todays_date;
134 $date = $m->tree->look_down(@{$s->{date}})->as_text() // $todays_date if
137 my $description = 'unknown';
139 $description = $m->tree->look_down(@{$s->{description}})->as_text();
141 my $position = 'Unknown';
143 $position = $m->tree->look_down(@{$s->{position}})->as_text();
145 print format_job($university,$position,$j_u->URI->abs(),$description,$date);
148 $m->follow_link(@{$s->{next_selector}}) or die "Unable to find next link";
153 my ($university,$position,$url,$text,$date) = @_;
154 $text = wrap(' ',' ',$text);
156 ** TODO $university -- $position