vendredi 1 décembre 2017

Ruby - Check URL for specific in-page result

I am a total newbie and worked out a ruby file that allows to check websites if they are live or if they return a 404 error. It looks like this:

#!/usr/bin/env ruby
# encoding: utf-8

urls = %w(
http://ift.tt/2jBywR0
)

require "open-uri"
require "nokogiri"

missing = []
urls.each do |url|
  begin
    open(url)
  rescue OpenURI::HTTPError => e
    if e.message == "404 Not Found"
      missing << url
      puts "#{url} is missing!"
    end
  end
end

Now, I want to change the script and check a long list of website URLs that do not give a 404 message but a "regular" website that says "this content is currently not available".

Thus, my question is: How do I have to change the code above in order to have result that indicates those URLs from the list that give out that message "this content is currently not available" ?

Thanks in advance for any help - also regarding how stupid my question might be for an experienced coder!

Much apprecitated! Tom

Aucun commentaire:

Enregistrer un commentaire