Created
January 13, 2016 16:12
-
-
Save od3n/d31fd624f62c85939fc1 to your computer and use it in GitHub Desktop.
Check Unifi availability
This file contains 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/env ruby | |
require "capybara" | |
require "capybara-webkit" | |
Capybara.configure do |config| | |
config.run_server = false | |
config.default_driver = :webkit | |
end | |
Capybara::Webkit.configure do |config| | |
config.allow_url "*" | |
config.ignore_ssl_errors | |
end | |
class UnifiBot | |
include Capybara::DSL | |
def initialize | |
Capybara.javascript_driver = :webkit | |
end | |
def scrape | |
show_status "Started .." | |
visit "https://occ.unifi.my/HSBBCustomerPortal/HSBBCustomerPortal.portal?_nfpb=true&_pageLabel=Hsbb_page_checkcoverage#wlp_Hsbb_page_checkcoverage" | |
select "SELANGOR", from: "stateList" | |
click_on "Landed (Terrace/Bungalow/Double-Storey)" | |
fill_in "ServiceabilityCheckStandalone{actionForm.streetNameMain}", with: "" | |
fill_in "ServiceabilityCheckStandalone{actionForm.postcode}", with: "" | |
click_button "Search" | |
visit "https://occ.unifi.my/HSBBCustomerPortal/HSBBCustomerPortal.portal?_nfpb=true&_windowLabel=ServiceabilityCheckStandalone&ServiceabilityCheckStandalone_actionOverride=%2Fportlets%2FgraniteAddressSearch%2FselectAddress&ServiceabilityCheckStandaloneaddressId=123" | |
if page.has_content? "We are sorry. The address is not UniFi serviceable" | |
show_status "HAHA. NO UNIFI" | |
else | |
show_status "Got UniFi" | |
end | |
show_status "Completed" | |
end | |
private | |
def show_status(msg) | |
current_time = Time.now.strftime('%H:%M:%S') | |
puts "[#{current_time}] #{msg}" | |
end | |
end | |
UnifiBot.new.scrape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment