Skip to content

Instantly share code, notes, and snippets.

@norman
Created February 25, 2011 18:02
Show Gist options
  • Save norman/844208 to your computer and use it in GitHub Desktop.
Save norman/844208 to your computer and use it in GitHub Desktop.
require "net/http"
require "uri"
def get_cpa(calle, altura)
url = "http://www3.correoargentino.com.ar/scriptsN/cpa/cpa_calle.idc"
res = Net::HTTP.post_form(URI.parse(url), {
:codloca => "5001",
:pnc => calle,
:alt => altura
})
regexp = /<big><font face="Arial" color="#002B6D"><b>([A-Z0-9]*)<br><\/b><\/font><\/big>/
return res.body.match(regexp)[1]
end
p get_cpa("Manuel Ugarte", 2158)
@etagwerker
Copy link

Possibly the quickest way Argentine institutions will provide 'web services'

@norman
Copy link
Author

norman commented Feb 25, 2011

LOL, unfortunately true. At very least I'm glad they're using plain old HTML rather than Flash or some other nonsense.

@pellegrino
Copy link

That is really useful! :)
Maybe here in Brazil we could also use this kind of web services hehe :)

@norman
Copy link
Author

norman commented Feb 25, 2011

Haha, I would just be happy if Brazilian web forms stopped asking people in other countries for a valid CEP! I can't tell you how many times I've had to Google for the format to defeat crappy form validation.

@pellegrino
Copy link

hahaha yeah, that is true! :)
But i think that is some kind of global issue, i can't remember how many times i had to find myself a zip code as well hehe

@djanowski
Copy link

Sólo para buscar desde la terminal: https://gist.github.com/869662

@tute
Copy link

tute commented May 14, 2011

Tanto más rápido que usando el sitio, gracias Norman! :-)

@tute
Copy link

tute commented Aug 2, 2011

Al final lo actualizaron y la interfaz web vuelve a ser fácil. Me di cuenta porque el código dejó de andar, bienvenida la renovación!

@norman
Copy link
Author

norman commented Aug 2, 2011

Excelente - en un mundo ideal no existirían estos gists. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment