]> git.donarmstrong.com Git - bin.git/blobdiff - jobs_to_org
remove convert_to_xls and .sa_bin
[bin.git] / jobs_to_org
index fcdfd35345aab2e61ffc34d3591c0414c6961ad8..d76392fa12acf57d5e45a50ba93f8c388025ccb5 100755 (executable)
@@ -115,6 +115,37 @@ my %sites =
                                      'page-title page-title--two-col'},
                            ],
               },
+     higheredjobs => {url => 'https://www.higheredjobs.com/search/advanced_action.cfm?JobCat=113&JobCat=259&JobCat=99&JobCat=100&JobCat=108&JobCat=107&PosType=1&InstType=1&InstType=2&InstType=3&Keyword=&Remote=1&Remote=2&Region=&Submit=Search+Jobs',
+                      next_selector_tree => [class => 'js-click-submit',
+                                             href => qr{advanced_action\.cfm},
+                                             sub {return 1
+                                                      if defined
+                                                      $_[0]->look_down(src =>
+                                                                       qr/active-right/);
+                                                  return 0;
+                                              },
+                                            ],
+                      job_selector => [url_regex => qr{^details.cfm\?JobCode=\d+},
+                                      ],
+                      university => [class => qr/field-value/,
+                                     sub {my $p = $_[0]->parent();
+                                    my $c = $p->look_down(class => qr/field-label/,
+                                                         );
+                                    defined $c and $c->as_text() =~ qr/institution/i;
+                                }
+                              ],
+                      date => [class => qr/field-value/,
+                               sub {my $p = $_[0]->parent();
+                                    my $c = $p->look_down(class => qr/field-label/,
+                                                         );
+                                    defined $c and $c->as_text() =~ qr/posted/i;
+                                }
+                              ],
+                      position => [id => 'jobtitle-header',
+                                   _tag => 'h1',
+                                  ],
+                      description => [id => 'jobDesc'],
+                     },
     );
 
 binmode STDOUT,":utf8";
@@ -130,12 +161,25 @@ sub get_jobs {
     if (not defined $sites{$site}) {
         die "Unknown site $site";
     }
+    print "* Jobs from $site\n";
     my $s = $sites{$site};
     $m->get($s->{url});
     for (1..$pages) {
         my %seen;
         my @job_urls = grep { ! $seen{ $_->URI()->abs() }++ }
             $m->find_all_links(@{$s->{job_selector}});
+        my $link;
+        if (exists $s->{next_selector}) {
+            ($link) = map {$_->URI()->abs()}
+                $m->find_all_links(@{$s->{next_selector}});
+        } elsif (exists $s->{next_selector_tree}) {
+            $link = $m->tree->look_down(@{$s->{next_selector_tree}});
+            if (not defined $link) {
+                $m->tree->dump;
+            }
+            die "Unable to find next link" unless defined $link;
+            $link = $link->attr('href');
+        }
         for my $j_u (sort @job_urls) {
             $m->get($j_u) or next;
             my $university = 'No university';
@@ -161,9 +205,9 @@ sub get_jobs {
                 $position = $m->tree->look_down(@{$s->{position}})->as_text();
             };
             print format_job($university,$position,$j_u->URI->abs(),$description,$date);
-            $m->back();
+            $m->back() or die "Unable to go back";
         }
-        $m->follow_link(@{$s->{next_selector}}) or die "Unable to find next link";
+        $m->get($link);
     }
 }