Created
May 9, 2013 21:39
-
-
Save jasdeepsingh/5550839 to your computer and use it in GitHub Desktop.
Scripting for Benefit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'net/http' | |
require 'uri' | |
require 'nokogiri' | |
require 'mail' | |
url = ###/tracktest.php | |
refnum = # my application reference number. | |
passport = # my passport number | |
uri = URI.parse(url) | |
response = Net::HTTP.post_form(uri, {"apptype" => "passport", "refno" => refnum, "passport_no" => passport, "submit" => "Submit"}) | |
page = Nokogiri::HTML(response.body) | |
if response.code == "200" | |
mail = Mail.new do | |
from '[email protected]' # don't spam here - email doesn't exist :) | |
to '[email protected]' | |
subject 'PCC Application Status' | |
html_part do | |
content_type 'text/html; charset=UTF-8' | |
body page.css('table') | |
end | |
end | |
mail.delivery_method :sendmail | |
mail.deliver | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment