Skip to content

Instantly share code, notes, and snippets.

@Archenoth
Last active August 3, 2022 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Archenoth/8bdebe84c523233339b5 to your computer and use it in GitHub Desktop.
Save Archenoth/8bdebe84c523233339b5 to your computer and use it in GitHub Desktop.
/r/nocontext fortune -- Fetches a random /r/nocontext title as the fortune
#!/usr/bin/env ruby
require 'nokogiri'
require 'net/http'
http = Net::HTTP.new("old.reddit.com", 443)
http.use_ssl = true
get = Net::HTTP::Get.new("/r/nocontext/", {
'User-Agent' => 'A fortune script that returns random /r/nocontext titles (Without context of course) (By /u/archenoth)'
})
puts Nokogiri.parse(http.request(get).body).css("a.title").to_a.sample.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment