# the 'bad news' voice makes it require 'nokogiri' require 'open-uri' require 'shellwords' # this is not what the code was started for but it's prob better 10.times do # wasn't meant initially to loop, would be better to get 10 at once and go from there xml = Nokogiri::XML.parse(open("https://en.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&format=xml")) say_me = xml.xpath("//api/query/random/page/@title") puts say_me say_safe = Shellwords.escape(say_me) %x[ say -v "Bad News" #{say_safe} ] end