Get a postcode based on IP address using Python

Is it possible to find a zip code based on a user's IP address using python / django (not geodjango)? I suppose I will have to use a web service, but I would really like to just query the database if possible.

I'm using geology right now, so it would be great if I could somehow integrate this.

+3
source share
2 answers

You cannot collect a real zip code from an IP address, because they are assigned by the provider during routing by dialing their connection.

-1
source

http://www.ip2location.com/python.aspx

import IP2Location;

IP2LocObj = IP2Location.IP2Location();
IP2LocObj.open("data/IP-COUNTRY-SAMPLE.BIN");
rec = IP2LocObj.get_all("19.5.10.1");

print rec.zipcode

, , , .

EDIT: , , , , , , - .

+1

Source: https://habr.com/ru/post/1733705/


All Articles