Skip to content

Instantly share code, notes, and snippets.

@sarahabimay
Last active January 20, 2021 09:16
Show Gist options
  • Save sarahabimay/7925d81bc6e9afbe954c89ea08a64cae to your computer and use it in GitHub Desktop.
Save sarahabimay/7925d81bc6e9afbe954c89ea08a64cae to your computer and use it in GitHub Desktop.
#!/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