[update] Foss Job script


Yesterday I wrote small script to get  fossjob . link was  here

Today I extended it . Int this

  1. we can search for job by date
  2. by range of date
  3. and by subject (i.e) ROR, PHPMYSQL etc.
  4. We can also see description of if we needed.

All these , we can see in terminal ;

Depenedencies for script to run,

ruby 1.8 and above

TODO

sudo apt-get install ruby libxml2 libxml2-dev libxslt-dev ruby-dev

sudo apt-get install rubygems

sudo gem install nokogiri

sudo gem install colorize

sudo gem install sanitize

Ruby Script

=begin
Program name: FossJob script
Date Written: 30/05/2011
Date Modified: 31/05/2011
Author : Sathianarayanan.S
License: GPL2.0
=end

require  'rubygems'
require 'nokogiri'
require 'open-uri'
require 'net/http'
require 'uri'
require 'colorize'   #colorizing the output
require 'date'
require 'sanitize'
#require 'active_support'

def description(link)
puts 'waiting'
@latest = Nokogiri::HTML(open(link))  #link - subject which you was entering eg. if you enter ror 'link' is http://fossjobs.in/jobs/ror/
desc = @latest.search('//div[@id="job-description"]')  #search for description of job
description =  desc.to_s.gsub('<br>', "\n")
puts 'Email : '+description.to_s.scan(/[a-z|A-Z|0-9]+@[a-z|A-Z]+.[a-z|.]{3,5}/).to_s.colorize(:color => :red)
puts Sanitize.clean(description)

end

def no_jobs
puts 'No jobs today'
end

def job_found(links, date)
if(links.count == 0)
puts 'No jobs Found'
else
puts "\nFor "+date+" - "+links.count.to_s+" Job was found\n".colorize(:color => :red)
links.each do |job|
link = job.to_s.scan(/http.+\/"/).to_s.chomp('"')
title = job.to_s.scan(/e=".+">/).to_s.gsub('e= >', '')
link_title = job.to_s.scan(/".*?"/).to_s.split('"')
puts link_title
link =  link_title[1].strip    #website link of job
title = link_title[3].strip     #title for job
puts "Title: "+title.colorize( :red )+"\n\nLink: "+link+"\n\n*********************************************************************************************\n\n"
print 'If you want description press "y" else "n" :'
ch = gets.chomp
case ch
when 'y'
description(link)
when 'n'
puts 'Thank U'
next
end
end
end
end

@dates = ''
@latest = Nokogiri::HTML(open('http://fossjobs.in/'))
def job_search(a)
puts a
link = @latest.search('//div[@id="content"]//span[text()=" '+ a+'"]/..//span//a[@href]')   #searching job with date
job_found(link,a)
end
def subject_search(a)
link = @recent.search('//div[@id="content"]//span[text()=" '+ a+'"]/..//span//a[@href]')  #searching job with subject
job_found(link,a)
end
while true
print "press \n'1' for search acccording to date..\n'2' for search in     range for date..\n'3 for search accroding to stream e.g PHP, ROR..\n'4' Quit \n\n"
a = gets.chomp
case a
when '1'
print 'Enter the date (dd/mm/yyyy) Default: today: '
date = gets.chomp
if date == ''
t = Time.now
t.strftime("%m-%d-%y")
date = t.strftime("%m-%d-%Y")
from = to = date
end
job_search(date.gsub('/', '-'))
when '2'
print 'From: [dd/mm/yy] '
from = gets
print 'To: [dd/mm/yy] '
to = gets
date_from =  Date.strptime(from, "%d/%m/%y")
date_to = Date.strptime(to, "%d/%m/%y")
date_from.upto(date_to) do |day|
job_search(day.strftime("%d-%m-%Y"))
end
when '3'
puts 'Enter by subject : eg. sysadmin, phpmysql, embedded, web, trainers, fossprojects, developers, java, mobile, perl, python etc: '
subject = gets.chomp
@latest = Nokogiri::HTML(open('http://fossjobs.in/jobs/'+subject))
print 'From: [dd/mm/yy] '
from = gets.chomp
print 'To : [dd/mm/yy] '
to = gets.chomp
if (to == '' && from == '')
t = Time.now
date = t.strftime("%d-%m-%Y")
from = to = date.gsub('/', '-')
end
puts from, to
date_from =  Date.strptime(from, "%d/%m/%y")
date_to = Date.strptime(to, "%d/%m/%y")
date_from.upto(date_to) do |day|
job_search(day.strftime("%d-%m-%Y"))
# puts day
end
when '4'
break
end
end

Sample Output

This slideshow requires JavaScript.

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in programs and tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink.

4 Responses to [update] Foss Job script

  1. Excellent job script! I’m pleased to read your script. I’m so inspire to read more of your script boss. Thankful to you. 🙂 🙂

  2. Arulalan.T says:

    Great dude…

    Everything ok.. But when we see more than one job, there should be some difference between each job….

    Use any character like ‘=’ or ‘#’ or ‘*’ or ‘-‘ or ‘_’ .By using this make a differential line among the continuous job descriptions.

    Wishes!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s