Created
December 30, 2011 19:46
-
-
Save randallb/1541195 to your computer and use it in GitHub Desktop.
Testing addresses for Utopia service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#txt = $("h1.street-address").text() #fron Trulia | |
txt = "56 East 7720 S, Midvale UT 84047" #bad | |
txt = "268 Park St, Midvale UT 84047" #good | |
htmler = "" | |
re1='(.*?),' | |
re2='.*?' | |
re3='((?:[a-z][a-z]+))' | |
re4='.*?' | |
re5='((?:(?:AL)|(?:AK)|(?:AS)|(?:AZ)|(?:AR)|(?:CA)|(?:CO)|(?:CT)|(?:DE)|(?:DC)|(?:FM)|(?:FL)|(?:GA)|(?:GU)|(?:HI)|(?:ID)|(?:IL)|(?:IN)|(?:IA)|(?:KS)|(?:KY)|(?:LA)|(?:ME)|(?:MH)|(?:MD)|(?:MA)|(?:MI)|(?:MN)|(?:MS)|(?:MO)|(?:MT)|(?:NE)|(?:NV)|(?:NH)|(?:NJ)|(?:NM)|(?:NY)|(?:NC)|(?:ND)|(?:MP)|(?:OH)|(?:OK)|(?:OR)|(?:PW)|(?:PA)|(?:PR)|(?:RI)|(?:SC)|(?:SD)|(?:TN)|(?:TX)|(?:UT)|(?:VT)|(?:VI)|(?:VA)|(?:WA)|(?:WV)|(?:WI)|(?:WY)))(?![a-z])' | |
re6='.*?' | |
re7='(\\d+)' | |
p = new RegExp re1+re2+re3+re4+re5+re6+re7,["i"] | |
m = p.exec txt | |
queryString = "inview=%2Fcgi-bin%2Fin1.pl%3Finview%3DI5-4&dosearch=1&address=#{escape m[1]}&unit=&city=#{escape m[2]}&state=#{escape m[3]}&zip=#{escape m[4]}" | |
console.log queryString | |
$.ajax | |
url: "http://utopianet.org/cgi-bin/in1.pl" | |
method: "POST" | |
success: (data)-> | |
htmler = data | |
unfortunatelyExists = htmler.indexOf("Unfortunately") | |
if unfortunatelyExists > -1 | |
console.log "No Utopia.", unfortunatelyExists | |
else | |
console.log "Yes Utopia!", unfortunatelyExists | |
data: queryString | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dude, if you're going to write some CoffeeScript, do it right, yo: