Code Monkey home page Code Monkey logo

google-ip-range-finder's Introduction

Google-IP-range-finder

This script will easily get all IPv4 ranges from official JSON file

Support with your โญ

How to use

Fisrt of all you need a JSON file otherwise this code won't work properly, in Amazon IP range finder and Gcore IP range finder I used direct link to read the file while in Google it was not possible due to sanctions. so I decided to read JSON file locally, In order to do so you need to download official file provided by google, Open this link and download the JSON file. change it's name to cloud.json if it is not this name.

Download this script and save it in any folder you like, in order to make the code run you need to place cloud.json file in same directory.

If you don't have python installed, install it from Python website.

Here's the code if you like to copy and paste

import json

def eafp(data: dict):
    """Easier to Ask Forgiveness than Permission"""
    ipv4s = []

    for prefix in data["prefixes"]:
        try:
            ipv4s.append(prefix["ipv4Prefix"])
        except KeyError:
            # This happens when "ipv4Prefix" is not in prefix
            pass

    return ipv4s


def get_data(path) -> dict:
    with open(path) as f:
        return json.load(f)


if __name__ == "__main__":
    data = get_data("cloud.json")
    #print(eafp(data))
    f_path = (r"ip.txt")
    with open (f_path ,'w') as d:
        for lang in eafp(data):
            d.write("{}\n".format(lang))

google-ip-range-finder's People

Contributors

hoseinnikkhah avatar

Stargazers

 avatar ZED avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.