Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Tim Morgan http://timmorgan.org

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Get a bible passage from the Living Stones / Seek-First Web Service with Ruby

require 'net/http'

LS_BASE_URL = 'http://www.seek-first.com/Bible.php?q=&passage=Seek'

def lookup_ls(reference, translation) # living stones (KJV, ASV, YLT, AKJV, WEB)
  return if reference.nil? or reference.empty?
  url = LS_BASE_URL + '&p=' + URI.escape(reference) + '&version=' + translation
  result = Net::HTTP.get(URI.parse(url))
  url = /<!\-\-\s*(http:\/\/api\.seek\-first\.com.+?)\s*\-\->/.match(result)[1]
  result = Net::HTTP.get(URI.parse(url)).gsub(/\s+/, ' ').gsub(/“|�/, '"').gsub(/‘|’/, "'").gsub('*', '')
  text = result.scan(/<Text>(.+?)<\/Text>/).map { |p| p[0].strip.gsub(/<.+?>/, '') }.join(' ') rescue nil
  return {:reference => reference, :text => text}
end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS