Skip to main content

A package to generate random IP addresses for a given country code

Project description

Random IP Generator

Random IP Generator is a Python package that generates a random IP address for a given country code. It uses the IP2LOCATION-LITE-DB1.CSV file as a source for IP ranges per country.

Installation

You can install the package via pip:

pip install random-ip-generator

Usage

After installing the package, you can use the random_ip_for_country function in your Python script to generate a random IP address for a given country.

from random_ip_generator import random_ip_for_country

country_code = "US"
random_ip = random_ip_for_country(country_code)
print(f"Random IP for {country_code}: {random_ip}")

get_country_codes() will return an alphabetically sorted list of country codes:

from random_ip_generator import get_country_codes

print(get_country_codes())

random_ip() will return a random ip from a random country:

from random_ip_generator import random_ip

print(random_ip())

Prerequisites

This package requires the ipaddress package. It will be installed automatically if you install random-ip-generator via pip.

Attribution

This site or product includes IP2Location LITE data available from https://lite.ip2location.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

random_ip_generator-0.2.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

random_ip_generator-0.2.0-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file random_ip_generator-0.2.0.tar.gz.

File metadata

  • Download URL: random_ip_generator-0.2.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for random_ip_generator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aee50d1d62d433923a4f9c54d607a6ee4bc141bc3e8f55c4c379e1cb25790d67
MD5 45a0509f4172cf89493516a4bcc5dc61
BLAKE2b-256 6292c1c4cfa179936ae8d8ae3050a2598f8314d1cfed8019c809767d4d05ce14

See more details on using hashes here.

File details

Details for the file random_ip_generator-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for random_ip_generator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad11972c2f22c5eae9a125aaaf4f57d5f3c1e0c25562c38162bddff879d55482
MD5 69eabff39c212845c3d18f414d4b6c24
BLAKE2b-256 3de4e8b260978dd36c201ea34ba2f55e0ddf5a8602d5e8f0e8186041b857bb85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page