|
#! /local/bin/perl
use strict;
use diagnostics;
use HTTP::Request::Common;
use LWP::UserAgent;
use CGI;
my $proxy;
my $jobserve ="class=\"Search\"\\s*href=\"(.*?)\">(.*?)\s*<\/a>";
my $monster = "MNSEven\">(.*?)<\/a>";
my $exp = "#f7f7f7\">.*?(.*?)<\/a>";
my $rcIreland = "jobsearchtitle\">(.*?)<\/span>.*?more details";
my $startParse ="";
my $data;
my $title;
my $link;
my @titles;
my @links;
my $sites = {};
my @siteInfo;
my $jobs ={};
my $buffer ="";
my $keyword = "";
my $englishKeyword = "";
my $escapedKeyword = "";
# make stdout hot.
my $ofh = select STDOUT;
$| = 1;
select $ofh;
if (defined $ENV{"QUERY_STRING"})
{
$buffer = $ENV{"QUERY_STRING"};
if($buffer)
{
$buffer =~ /keyword=(.*)/i;
if($1)
{
$keyword = $1;
$englishKeyword .= $keyword;
$englishKeyword =~ s/%([A-Fa-f\d]{2})/chr hex $1/eg;
$escapedKeyword = $englishKeyword;
$escapedKeyword =~ s/\+/\\+/g;
$escapedKeyword =~ s/\?/\\?/g;
logUserInfo();
}
}
}
sub logUserInfo
{
my $q = new CGI;
my $remoteHost = $q->remote_host();
my $referrer = $q->referer();
my $userName = $q->user_name();
my $time = localtime();
open(LOG, ">>/webtree/s/shimoda/logs/jobSearchLog.txt");
print LOG "[$time] - $remoteHost,$englishKeyword,$userName,$referrer\n";
}
sub enc
{
my ($word) = $_[0];
$word =~ s/([^\w()'*~!.-])/sprintf '%%%02x', $1/eg;
return $word;
}
sub dec
{
my ($word) = $_[0];
$word =~ s/%([A-Fa-f\d]{2})/chr hex $1/eg;
return $word;
}
sub setupSites()
{
my @proxies;
push(@proxies,'http://proxy1.dcu.ie:3128');
push(@proxies,'http://proxy2.dcu.ie:3128');
push(@proxies,'http://proxy3.dcu.ie:3128');
my $ua = LWP::UserAgent->new;
foreach my $p (@proxies)
{
$ua->proxy(['http', 'ftp'], $p);
my $res = $ua->request(GET "http://www.redbrick.dcu.ie");
if($res->is_success)
{
$proxy = $p;
last;
}
}
my $entry = {};
$entry->{PARSE} = $monster;
$entry->{URL} = "http://jobsearch.monster.ie";
my $varz="brd=1\&cy=IE\&jt=2\&jt=1\&jt=4\&jt=3\&q=$keyword\&sort=rv&vw=d";
$entry->{FETCH} ="http:\/\/jobsearch\.monster\.ie/jobsearch.asp\?$varz";
$entry->{NUM_JOBS} = 0;
push @{ $sites->{"www.monster.ie"}->{ENTRIES}}, $entry;
$entry = {};
$entry->{PARSE} = $exp;
$entry->{URL} = "http://www.exp.ie/";
$entry->{FETCH} = "http:\/\/www.exp.ie\/query_new.asp\?IsProvince=1\&MatchPerc=40".
"\&Ranking=\&Roles=\&Recruiter=Both\&Category=3\&Location=0".
"\&referrer=local\&KEYWORDS=$keyword\&I7.x=0\&I7.y=0";
$entry->{NUM_JOBS} = 0;
push @{ $sites->{"www.exp.ie"}->{ENTRIES}}, $entry;
$entry = {};
$entry->{PARSE} = $jobserve;
$entry->{URL} = "http://www.jobserve.co.uk/";
my $tempKy = "$keyword+and+ireland";
my $vz = "\?jobType=\*\&d=7\&page=1\&q=$tempKy\&x=25\&y=9\&order=Rank";
$entry->{FETCH}="http:\/\/www.jobserve.co.uk\/searchresults.aspx$vz";
$entry->{NUM_JOBS} = 0;
push @{ $sites->{"www.jobserve.co.uk"}->{ENTRIES}}, $entry;
my $rcIvars="\?JobType=ACTIVE,%20ACTIVE\&County=None\&Keyword=$keyword\&B12x=\&B12y=\&myDate=2days";
$entry = {};
$entry->{PARSE} = $rcIreland;
$entry->{URL} = "http://recruitIreland.ie/";
$entry->{FETCH}="http:\/\/www.recruitireland.com\/jobsearch.asp$rcIvars";
$entry->{NUM_JOBS} = 0;
push @{ $sites->{"www.RecruitIreland.ie"}->{ENTRIES}}, $entry;
1;
}
sub getHeader()
{
my $ret;
$ret .= <
";
}
return $ret;
}
sub getFooter()
{
my $ret;
if($keyword)
{
$ret .= <
END
}
else
{
$ret .= "