获取云提供程序NetBlocks

netblocks的Python项目详细描述


网锁

这不是谷歌的官方产品。

此模块按照以下链接递归检索DNS条目

The GCE ranges
    https://cloud.google.com/compute/docs/faq#where_can_i_find_product_name_short_ip_ranges
The Google Services ranges
    https://support.google.com/a/answer/60764
The AWS ranges
    https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

pip install netblockspip install git+https://github.com/hm-distro/netblocks/

安装包

fetch()方法的默认参数值为initial_dns_list=[GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS, GOOGLE_INITIAL_SPF_NETBLOCK_DNS]

其中

#The GCE ranges
GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS = "_cloud-netblocks.googleusercontent.com"

#The Google Services ranges
GOOGLE_INITIAL_SPF_NETBLOCK_DNS= "_spf.google.com"

#The AWS ranges
AWS_IP_RANGES="https://ip-ranges.amazonaws.com/ip-ranges.json"

请参见here了解如何在谷歌应用程序引擎中使用此模块

API使用

import netblocks
cidr_blocks = set()
api = netblocks.NetBlocks()
try:
    # returns both GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS and GOOGLE_INITIAL_SPF_NETBLOCK_DNS
    cidr_blocks = api.fetch()
    
    # To get only the SPF list use the below:
    #  cidr_blocks = api.fetch([netblocks.GOOGLE_INITIAL_SPF_NETBLOCK_DNS])

    
    # To get only the GCE list use the below:
    #  cidr_blocks = api.fetch([netblocks.GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS]) 
    
    # To get only the AWS list use the below:
    #  cidr_blocks = api.fetch([netblocks.AWS_IP_RANGES]) 
    
    """
    The cidr_blocks set contains strings like the below
    ip4:146.148.2.0/23
    ...
    ip6:2600:1900::/35
    """
    
except netblocks.NetBlockRetrievalException as err:
    #exception handling
    pass

语言

依赖关系

请求

许可证

apache 2.0;详细信息请参见LICENSE

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java高并发应用程序?   java通过Gmail API谷歌应用程序引擎发送电子邮件   JAVAutil。scanner scanner hasNextLine()无法访问Java中的最后一行   如何处理xpath、Selenium Webdriver、Java的变化   java哪种设计模式最适合避免方法中的多个参数   java运行同一应用程序的tomcat的两个实例能否为两个不同的用户创建相同的sessionId?   java播放声音对我来说不起作用   java LibGDX场景2D:对单独类中的参与者应用操作   使用SpringMVC发送html邮件的java空指针异常   java Axis2 adb和minInclusive=2147483648   java试图以随机顺序输出列表数组的文本,但我一直在使用textView时出错。setText(myList[rando]);   java Eclipse在任何子字符串上进行多行编辑,如Sublime Text和Atom   java在GWT中从属性文件动态加载值   检查用户是否输入整数或字符串   java打印具有相同字符的行中的重复字符   在phonegap应用程序中将java变量从Android活动传递到javascript   java如何在swing中将键绑定设置为可编辑JTable?   java方法修改超出范围的方法   java是链表中的节点类,特别是构造函数,并使用它创建随机整数的链表