Last active
January 20, 2021 09:16
-
-
Save sarahabimay/7925d81bc6e9afbe954c89ea08a64cae to your computer and use it in GitHub Desktop.
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 'net/http' | |
require 'uri' | |
require 'nokogiri' | |
require 'open-uri' | |
uri = URI('https://reports.cloud-platform.service.justice.gov.uk/hosted_services') | |
document = Nokogiri::HTML.parse(URI.open(uri)) | |
unless document.nil? | |
# the xpath below is super fragile | |
document.xpath('//tr/td[6]/a').each do |node| | |
href = node[:href] | |
unless href.nil? | |
response = Net::HTTP.get_response(URI(href)) | |
puts "Node: #{href} is up? #{response.code == '200'}" | |
end | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment