def query_censys(api: CensysHosts, query: str, max_results=1000) -> set[str]:
    """Queries Censys and returns all identified IP addresses."""
    ip_addresses: set[str] = set()
    if max_results <= 0:
        results = api.search(query, fields=["ip"], pages=-1)
    elif max_results < 100:
        results = api.search(query, fields=["ip"], per_page=max_results, pages=1)
    else:
        pages = math.ceil(max_results / 100)
        results = api.search(query, fields=["ip"], per_page=100, pages=pages)

    for result in results:
        for record in result:
            ip = record.get("ip")
            if ip is not None:
                ip_addresses.add(ip)

    return ip_addresses
Queries Censys and returns all identified IP addresses.
plugins/analytics/public/censys.py