python/django 中的邮件地址验证

发布于 2024-09-15 11:03:21 字数 166 浏览 11 评论 0原文

我们正在 django 框架和 python 中开发我们的网站。目前我们正在寻找一个 API/工具来验证用户输入的物理地址。它不需要非常复杂。我们只需要避免垃圾邮件注册即可。对于此步骤,我们需要验证国家、州、城市和邮政编码是否彼此所属。例如,伯克利作为邮政编码 94704 的城市并不属于纽约州,等等。 有什么想法吗?

We are developing our website in django framework and with python. currently we are looking for an api/a tool to validate the physical addres the user enters. It doesn't need to be vey sophisticated. We just need to avoid spam registrations. For this step, we need to verify if country, state, city, and zipcode are belong to each other. For instance, Berkeley as a city with Zipcode 94704 is not in NY state, etc.
Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉 2024-09-22 11:03:21

您可以尝试pygeocoder。它是 Google 地理编码 V3 API 的 Python 包装器。它可以满足您的一些验证需求。

from pygeocoder import Geocoder
g = Geocoder()
g.geocode("1 wellington, ottawa").valid_address
>>> True
g.geocode("1 wellington, chicago").valid_address
>>> False

也可能会出现一些小拼写错误

result = g.geocode("1600 amphiteather, mountain view")
result.valid_address
>>> True
print result
>>> 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA
g.geocode("16000000 amphitheater, mountain view").valid_address
>>> False

,但谷歌并不总是有正确的邮政编码。我相信 USPS 有一个针对美国的公共 API。

免责声明:我制作了 pygeocoder

You can give a try to pygeocoder. It's a Python wrapper for Google's Geocoding V3 API. It can fulfill some of your validation needs.

from pygeocoder import Geocoder
g = Geocoder()
g.geocode("1 wellington, ottawa").valid_address
>>> True
g.geocode("1 wellington, chicago").valid_address
>>> False

It can take some minor misspelling too

result = g.geocode("1600 amphiteather, mountain view")
result.valid_address
>>> True
print result
>>> 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA
g.geocode("16000000 amphitheater, mountain view").valid_address
>>> False

But Google doesn't always have the right postal/zip code. USPS has a public API for the US I believe.

disclamer: I made pygeocoder

无声无音无过去 2024-09-22 11:03:21

您可以使用地理编码服务(例如 Google 的)来验证地址是否存在。

You could probably use a GeoCoding service (like Google's) to verify that an address exists.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文