tomas-net / ip2geotools Goto Github PK
View Code? Open in Web Editor NEWSimple tool for getting geolocation information on given IP address from various geolocation databases.
License: MIT License
Simple tool for getting geolocation information on given IP address from various geolocation databases.
License: MIT License
When applying the following function to a quite large (2k) pandas column of IP addresses
from ip2geotools.databases.noncommercial import DbIpCity
def ip_location(ip_address):
response = DbIpCity.get(ip_address)
return (response.country, response.city)
roughly after processing 10% of it, the system return this error
KeyError Traceback (most recent call last)
<ipython-input-5-f4580d09d702> in <module>
1 tqdm.pandas(desc="IP!")
----> 2 df['User_location'] = df['User IP'].progress_apply(utils.ip_location)
/usr/local/lib/python3.6/dist-packages/tqdm/_tqdm.py in inner(df, func, *args, **kwargs)
720 # Apply the provided function (in **kwargs)
721 # on the df using our wrapper (which provides bar updating)
--> 722 result = getattr(df, df_function)(wrapper, **kwargs)
723
724 # Close bar and return pandas calculation result
/usr/local/lib/python3.6/dist-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
4040 else:
4041 values = self.astype(object).values
-> 4042 mapped = lib.map_infer(values, f, convert=convert_dtype)
4043
4044 if len(mapped) and isinstance(mapped[0], Series):
pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
/usr/local/lib/python3.6/dist-packages/tqdm/_tqdm.py in wrapper(*args, **kwargs)
716 # take a fast or slow code path; so stop when t.total==t.n
717 t.update(n=1 if not t.total or t.n < t.total else 0)
--> 718 return func(*args, **kwargs)
719
720 # Apply the provided function (in **kwargs)
/mnt/c/Users/michal/Desktop/MateCat-timings/code/utils.py in ip_location(ip_address)
79
80 def ip_location(ip_address):
---> 81 response = DbIpCity.get(ip_address)
82 return (response.country, response.city)
/usr/local/lib/python3.6/dist-packages/ip2geotools/databases/noncommercial.py in get(ip_address, api_key, db_path, username, password)
65 # format data
66 ip_location.country = content['countryCode']
---> 67 ip_location.region = content['stateProv']
68 ip_location.city = content['city']
69
KeyError: 'stateProv'
Getting this error, when basic program in python
I can see only tow letters from country name , and there is no option to see all name
All the requirements versions in requirements.txt are precise (using "==").
This is a bad practice: it means that the library won't work in any environment that uses different versions of these libraries (e.g. due to conflicting requirements).
The requirements should be in the form of ">=", unless there's a very good reason to do otherwise.
Hi, I have a python script that collects location information for SSH brute force attacks on my server, about 2 days ago I noticed that every request is returning a "ERROR - 403 Client Error: Forbidden for url" error.
I am a little perplexed by this since I only scan less than 500 IPs per day, any clue as to why I am being rate limited?
Thank you.
I work for IPinfo and I appreciate the project featuring IPinfo. IPinfo provides keyless access to the API service and a generous limit for that as well. In the tokenless access, we also provide HTTPS/SSL encryption. Our data is one of the most accurate geolocation data backed by our probe network.
Without an access token, users can make up to 1,000 requests per day. Users can also sign up for a free account and get a limit of 50,000 requests per month. If you are looking to add more functionality, you can also check out our free IP database. Please let me know what you think. Thanks!
Tried with the example given in the document but it returns InvalidRequesterror()
from ip2geotools.databases.noncommercial import DbIpCity
response = DbIpCity.get('147.229.2.90', api_key='free')
response.ip_address
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sbc/anaconda3/lib/python3.7/site-packages/ip2geotools/databases/noncommercial.py", line 60, in get
raise InvalidRequestError()
ip2geotools.errors.InvalidRequestError
I can't download this module, here is the error:
Collecting ip2geotools Using cached https://files.pythonhosted.org/packages/97/de/addc2a0db7e2584f3fa960549c15439cfab70c30935ee453fb938e75de6e/ip2geotools-0.1.4.tar.gz Requirement already satisfied: Click==7.0 in /usr/lib/python2.7/dist-packages (from ip2geotools) (7.0) Collecting IP2Location==8.0.3 (from ip2geotools) Using cached https://files.pythonhosted.org/packages/b3/ec/0ea7279a022fc2fb98c680fce8c7527486a927c67f855aba18b4af30e06d/IP2Location-8.0.3.tar.gz Collecting Pygments==2.3.0 (from ip2geotools) Using cached https://files.pythonhosted.org/packages/fc/41/4f900a7852e25bb9350b4e3ee8c4aba0ee32abefd401456962b25f954823/Pygments-2.3.0-py2.py3-none-any.whl Collecting astroid==2.1.0 (from ip2geotools) Could not find a version that satisfies the requirement astroid==2.1.0 (from ip2geotools) (from versions: 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.8, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6) No matching distribution found for astroid==2.1.0 (from ip2geotools)
Does the package support batch processing of IP addresses based on a list? I tried to create a simple 2 address list and ran the query, but got a IPaddressNotFoundError
Hello, I had a problem when importing a module (in the documentation, the first line from the code). The following error occurs:
File "/data/data/com.termux/files/home/downloads/ip2tools.py", line 1, in
from ip2geotools.databases.noncommercial import DbIpCity
ModuleNotFoundError: No module named 'ip2geotools'
could you help me? I'm 14 and I'm just starting to program, so I don't really understand, please help me.
Building wheels for collected packages: typed-ast
Building wheel for typed-ast (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for typed-ast (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-312
creating build\lib.win-amd64-cpython-312\typed_ast
copying typed_ast\ast27.py -> build\lib.win-amd64-cpython-312\typed_ast
copying typed_ast\ast3.py -> build\lib.win-amd64-cpython-312\typed_ast
copying typed_ast\conversions.py -> build\lib.win-amd64-cpython-312\typed_ast
copying typed_ast_init_.py -> build\lib.win-amd64-cpython-312\typed_ast
creating build\lib.win-amd64-cpython-312\typed_ast\tests
copying ast3\tests\test_basics.py -> build\lib.win-amd64-cpython-312\typed_ast\tests
running build_ext
building '_ast27' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for typed-ast
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.