Skip to content

iptoolbox 0.0.2

vlad edited this page Aug 29, 2022 · 2 revisions



Repository pypi Documentation BugTracker





install

python3 -m pip install iptoolbox==0.0.2

Features

  • RandomIp4 class is for creating random IP

  • class iptoolbox.RandomIp4()

    iptoolbox.RandomIp4(country_code: set = "ALL", random_seed=None)

    RandomIp4 class is for creating random IP

    • Parameters:
      • country_code (set, optional): - Enter the country code or you can enter ALL instead of the country code. In this case, the generated IP can be for any country . Defaults to ALL.
      • random_seed (str or int, optional): - used to initialize the random ip generator . Defaults to None.
    • Returns
      • type: None



    • methods

      • method generate_ip()

        Use generate_ip to generate an IP. It will return the created IP to you and add it to the ip_list list

        • Returns:
          • str: ip v4



    • Examples:

      • simple :

        import iptoolbox
        r = iptoolbox.RandomIp4()
        print(r.generate_ip())
        

        139.81.25.43

      • using with :

        import iptoolbox
        with iptoolbox.RandomIp4(country_code="IR") as r:
            print(r.generate_ip())
        

        185.8.173.203

      • using a for loop :

        import iptoolbox
        with iptoolbox.RandomIp4(country_code="US") as r:
            for _ in range(10): 
                r.generate_ip()
            print(r.ip_list)
        

        ['205.252.16.87', '50.0.53.6', '154.26.1.61', '149.14.14.36', '130.244.138.15', '151.139.41.225', '200.186.105.44', '220.158.255.80', '199.180.221.10', '69.172.213.166']

      • using seed :

        import iptoolbox
        with iptoolbox.RandomIp4(country_code="US", random_seed=24) as r:
            for _ in range(10): 
                r.generate_ip()
            print(r.ip_list)
        

        ['204.246.205.39', '216.250.193.77', '63.218.150.66', '63.110.213.250', '63.146.54.87', '199.189.209.223', '204.98.216.96', '213.151.35.145', '206.71.103.208', '130.244.2.49']

Clone this wiki locally