Skip to content

Instantly share code, notes, and snippets.

@jasdeepsingh
Created May 9, 2013 21:39
Show Gist options
  • Save jasdeepsingh/5550839 to your computer and use it in GitHub Desktop.
Save jasdeepsingh/5550839 to your computer and use it in GitHub Desktop.
Scripting for Benefit
#!/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 'no-reply@jasdeep.ca' # don't spam here - email doesn't exist :)
to 'my-email-address@domain.com'
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