/examples/crack.rb

http://github.com/jnunemaker/httparty · Ruby · 19 lines · 15 code · 4 blank · 0 comment · 0 complexity · 9a535fa8f2470d5f9f07f184820c5137 MD5 · raw file

  1. require 'rubygems'
  2. require 'crack'
  3. dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
  4. require File.join(dir, 'httparty')
  5. require 'pp'
  6. class Rep
  7. include HTTParty
  8. parser(
  9. proc do |body, format|
  10. Crack::XML.parse(body)
  11. end
  12. )
  13. end
  14. pp Rep.get('http://whoismyrepresentative.com/getall_mems.php?zip=46544')
  15. pp Rep.get('http://whoismyrepresentative.com/getall_mems.php', query: { zip: 46544 })