Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
在IRB中:
In IRB:
一个更轻量级的选项是Area gem。
A more lightweight option is the Area gem.
请参阅杰森的回答。效果很好。
问题是,除非您付费,否则美国邮政局不允许批量下载其邮政编码列表。 Splashlin 提到的 gem 中使用的 Google API 似乎不再支持城市和州,而是现在返回区号:
此页面显示了您可以自行实施的一些方法。不过,数据来源可能不是最新的:
http://www.ruby-forum.com/主题/48815
See Jason's answer. It works nicely.
The problem is that the USPS doesn't allow bulk downloads of their zip-code lists unless you pay for it. Google's API, which is used in the gem mentioned by Splashlin, no longer seems to support the city and state, instead it now returns the area code:
This page shows some ways you could roll your own. The sources of the data might not be current though:
http://www.ruby-forum.com/topic/48815