Metadata-Version: 2.4
Name: ipinfaux
Version: 0.0.1
Summary: Unofficial ipinfo.io scraper using BeautifulSoup
Author-email: Knopplie Lastname <knopplielastname@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/knopplie/ipinfaux
Project-URL: Repository, https://github.com/knopplie/ipinfaux
Project-URL: Issues, https://github.com/knopplie/ipinfaux/issues
Project-URL: Bug Tracker, https://github.com/knopplie/ipinfaux/issues
Keywords: ipinfo,ip-geolocation,geolocation,ip,scraper,beautifulsoup
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: Proxy Servers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: pytest>=7.0.0
Requires-Dist: black>=23.0.0
Requires-Dist: isort>=5.12.0
Requires-Dist: mypy>=1.0.0
Requires-Dist: build>=0.10.0
Requires-Dist: twine>=4.0.0
Requires-Dist: asyncio>=3.4.3
Dynamic: license-file

# ipinfaux

Unofficial ipinfo.io scraper. Gets IP data using a JWT token.

## install

```bash
pip install ipinfaux
```

## quick start

### get a jwt token (login)

```python
from ipinfaux import GetJWTByLogin

# login with email/password
jwt = GetJWTByLogin.login("your@email.com", "yourpassword")

# or with a proxy
jwt = GetJWTByLogin.login("your@email.com", "yourpassword", "http://proxy:8080")
```

### lookup an ip

```python
from ipinfaux import GetFullData

# use your jwt token
data = GetFullData("8.8.8.8", "your-jwt-token")

# check if it worked
if data.error:
    print(f"failed: {data.error}")
else:
    # access data
    print(data.summary)
    print(data.geolocation)
    print(data.privacy)
```

## examples

### get data as json

```python
data = GetFullData("1.1.1.1", jwt)
print(data.as_json())     # print json
data.save()               # save to ipinfo_1.1.1.1.json
data.save("custom.json")  # save to custom file
```

### get data as csv

```python
data = GetFullData("8.8.8.8", jwt)
print(data.as_csv())      # print csv
data.save_csv()           # save to ipinfo_8.8.8.8.csv
data.save_csv("data.csv", delimiter=",")
```

### multiple ips

```python
ips = ["8.8.8.8", "1.1.1.1", "9.9.9.9"]
results = []

for ip in ips:
    data = GetFullData(ip, jwt)
    if not data.error:
        results.append(data)
        print(f"{ip}: {data.geolocation.get('city')}")

# save all to one csv
if results:
    results[0].save_csv_batch(results, "all_ips.csv")
```

## data structure

```json
{
  "ip": "8.8.8.8",
  "summary": {
    "asn": "AS15169",
    "rpki": true,
    "asn_name": "Google LLC",
    "hostname": "dns.google",
    "range": "8.8.8.0/24",
    "company": "Google LLC",
    "hosted_domains_count": 20572,
    "privacy": true,
    "anycast": true,
    "asn_type": "hosting",
    "abuse_email": "network-abuse@google.com"
  },
  "geolocation": {
    "city": "Mountain View",
    "state": "California",
    "country": "United States",
    "country_code": "us",
    "postal": "94043",
    "timezone": "America/Los_Angeles",
    "latitude": 37.4056,
    "longitude": -122.0775
  },
  "privacy": {
    "hosting": true,
    "vpn": false,
    "proxy": false,
    "tor": false,
    "relay": false,
    "residential_proxy": false,
    "details": {}
  },
  "asn": {
    "asn": "15169",
    "asn_name": "Google LLC",
    "domain": "google.com",
    "asn_type": "hosting"
  },
  "abuse": {
    "address": "Mountain View, 1600 Amphitheatre Parkway, 94043",
    "phone": "+1-650-253-0000",
    "email": "network-abuse@google.com",
    "name": "Abuse",
    "network": "8.8.8.0/24"
  },
  "domains": {
    "count": 15,
    "domains": [
      "hdchina.org",
      "55188.com",
      "ymck.me",
      "ymjump.com",
      "musicool.cn",
      "viewpointcloud.com",
      "itempurl.com",
      "authrock.com",
      "gbwhatspro.com",
      "epicloud.link",
      "btempurl.com",
      "mysapo.vn",
      "everincloud.com",
      "farglory-hotel.com.tw",
      "raptorx.co"
    ]
  },
  "tags": {
    "airplane": false,
    "airport": false,
    "anycast": true,
    "bittorrent": false,
    "cdn": true,
    "cloud": false,
    "crawler": false,
    "geodns": false,
    "hosting": true,
    "hotel": false,
    "hotspot": false,
    "ix": false,
    "mailserver": false,
    "mobile": false,
    "nameserver": false,
    "portscan": false,
    "proxy": false,
    "relay": false,
    "router": false,
    "satellite": false,
    "ssh": false,
    "tor": false,
    "vpn": false,
    "webserver": true,
    "bus_station": false,
    "conference_center": false,
    "coworking_space": false,
    "in_transit": false,
    "library": false,
    "sports_center": false,
    "stadium": false,
    "subway_station": false,
    "train_station": false
  },
  "other_providers": {
    "exists": false,
    "city": null,
    "state": null,
    "country_code": null,
    "distance_km": null,
    "distance_text": null,
    "full_text": null
  }
}
```

## fields explained

- **summary** - basic ip info (asn, hostname, company)
- **geolocation** - where the ip is located
- **privacy** - if ip is vpn/proxy/tor etc
- **asn** - autonomous system details
- **abuse** - who to contact for abuse
- **domains** - domains hosted on this ip
- **tags** - what kind of ip it is (cdn, hosting, etc)
- **other_providers** - only applicable if ipinfo thinks its wrong, shows what maxmind thinks

## requirements

- python 3.7+
- requests
- beautifulsoup4

## license

mit
