在 Python 中跟踪 IP 地址

发布于 2024-10-04 06:15:27 字数 438 浏览 0 评论 0原文

对于我的编程入门课程的大学项目,我决定制作一个小软件来跟踪 IP 地址并将其很好地放在 GUI (PyQt) 上。我知道没什么大不了的,但我仍然喜欢这个主意。

所以我在 Google 上搜索了一下,找到了 MaxMind 的 IP 及其免费产品以及 pygeoip,这是一个 API用于 MaxMind GeoIP 数据库。很酷,嗯!

但缺点是要查询他们的数据库,我必须下载乡村城市的单独数据库。这不太好,因为我必须让最终用户下载额外的文件(以 MB 为单位)才能查找 IP 地址。

所以我想知道,还有其他方法可以做到这一点吗?如何追踪 IP 地址?请注意,如果可能的话,我需要将它们细化到城市级别。像这个人一样的东西 arulljohn.com/track.pl

谢谢!

For a college project for my course on Introduction to Programming, I decided to make a small software that traces the IP address and puts them nicely on a GUI (PyQt). Not a big deal I know, but still I like the idea.

So I Googled around and found MaxMind's IP and their free offering and the pygeoip, which is an API for the MaxMind GeoIP databases. Pretty cool, eh!

But the downside is that to query their database, I have to download individual databases for country city. This is not good cause I have to make the end user download additional files (in MBs) just to look up an IP address.

So I am wondering, is there another method of doing this? How do I trace IP addresses? Note that I need them down to the city level, if possible. Something like this guy aruljohn.com/track.pl

Thanks!

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

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

发布评论

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

评论(2

老娘不死你永远是小三 2024-10-11 06:15:27

我更喜欢“pygeoip”,因为它允许您在本地开发完整的解决方案。当然,您需要保留数据库。

如果您不想在本地保留数据库,则必须依赖外部服务来查询 IP 的位置。这将使您的解决方案保持小型但依赖于此服务。

为此,请查看:ipinfodb.com

他们提供 JSON 和 XML API 接口,应该非常容易构建。

查看更多信息:http://ipinfo.info/html/geolocation_2.php

I would have preferred "pygeoip", because it allows you to develop a complete solution locally. Of course, you will need to keep the database.

If you do not want to keep the database locally, you will have to depend on an external service to query for location of an IP. This will keep your solution small but dependent on this service.

For this check out: ipinfodb.com

They provide JSON and XML APIs interface which should be sufficiently easy to build.

Check out more information at : http://ipinfo.info/html/geolocation_2.php

鱼窥荷 2024-10-11 06:15:27

我还有更好的主意。为什么不制作一个非常简单的网络应用程序,它将进行实际的查找?你的 PyQt 客户端会对此进行 HTTP 请求。或者也许在这种情况下您甚至不需要客户。只需制作一个网页即可获取 IP 地址并显示城市。

I have even better idea. Why don't you make a very simple web app, which will do the actual look up; and you PyQt client would do HTTP request to that. Or maybe in that case you don't even need a client. Just make a web page to get IP address and show city.

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