Practical Tools with Python — IP Query for Location

Hakan KOCAMAN
3 min readMay 29, 2020

Until today, I have shared almost all of the personal work I have done, I have received many good feedbacks about the work I have shared, and sometimes even new studies have been created within this framework by evaluating every feedback I have received. So much so that I believed that the main thing is the idea and if there is a problem, I wanted to find a solution. So over time, I came up with a lot of little tools written in Python.

With this series of articles, I plan to share these Python tools, which come out over time, with their codes and emergence stories. In addition, as a result of the interaction that will emerge on these occasions, I hope to sail new problems and solutions as much as possible.

You can access the codes written in Python in the article series from my GitHub page, the links of which I share below, and the video narrations on my Youtube channel.

GitHub: https://github.com/hakankocaman
Youtube: https://www.youtube.com/hakankocaman

IP Query for Location

Without further ado, let’s talk about how our first tool, IP Query, came about and its usage. In order to introduce and present a few modules that we have recently commissioned on a My Business website, users were asked to know which city and countries the modules were used by. Because the issue was urgent and the request came out of office hours, I decided to solve it on my own, without disturbing the software developer friends. First of all, I provided a list of the threads with which the modules are used from the log records of the system. Then, as a result of a little research on the internet, I found several websites that provide the location and other data of the address via the ip address. When I examined the overall of these, almost all of them offered the opportunity to query with a single thread, while the service provider I used in the related vehicle also allowed the query with many threads. It even offered api for multiple queries. It remains to query about 300 ip addresses that I have in just one for loop. By writing the IP Inquiry tool with Python, I quickly obtained the country, province, county, latitude and longitude values ​​of the relevant ip addresses provided by the service provider. Of course, I made a thematic map using the latitude and longitude values ​​in the data I obtained later and prepared it for presentation and forwarded it to the relevant authority.

You can obtain the Python codes of the IP Query tool from the GitHub page below and watch the Youtube video prepared for the use of the tool.

GitHub: https://github.com/hakankocaman/PratikPythonAraclari

--

--