POWER OF NOKOGIRI GEM
Yesterday I wrote a small script in ruby after i saw about ‘Nokogiri’ gem in ruby
Nokogiri is html/xml parser which more faster than ‘Hpricot’.
sudo apt-get install ruby libxml2 libxml2-dev libxslt-dev ruby-dev
sudo apt-get install rubygems
sudo gem install nokogiri
Code which I written was , It will see fossjobs.in website for job which was posted today . If there is no job posted today it will show result as ‘Job not found today’ as output .
If there is job posted today , It will ask for mobile numbers , You can give any number of mobile you want . Then it will send to all numbers about Job title which was posted today
require 'rubygems' require 'nokogiri' require 'open-uri' require 'net/http' require 'uri' t = Time.now t.strftime("%m-%d-%y") date = t.strftime("%m-%d-%Y") date = '21-05-2011' # Get a Nokogiri::HTML:Document for the page we’re interested in... doc = Nokogiri::HTML(open('http://fossjobs.in/')) # Do funky things with it using Nokogiri::XML::Node methods... #### # Search for nodes by css job = nil doc.css('#content div span').each do |link| #dates.push(link.content) if link.content.include? date job = link.parent.children.css('span.row-info a').text end end if job.nil? job = 'Job Not Posted Today' puts job else print 'Enter your mobile number (seperated by comas):' mob = gets mob.each do |num| Net::HTTP.get_print URI.parse('http://s1.freesmsapi.com/messages/send?skey=51571862189c268930bf0d697b4a8d38&message='+job.gsub(' ', '')+'&senderid=12345678&recipient='+num) end end
for testing you can give default date as ’21-05-2011′ in same format in code above
date = ’21-05-2011′
. This is will return ‘LinuxSystemAdminstator-Immediate’
you can Check all job updates from your script 🙂