diff --git a/censys/search/v2/api.py b/censys/search/v2/api.py index 3da9359b..1edc2ddb 100644 --- a/censys/search/v2/api.py +++ b/censys/search/v2/api.py @@ -100,6 +100,9 @@ class Query(Iterable): For more details, see our documentation: https://search.censys.io/api """ + # Total number of results (Set after first query) + total: Optional[int] = None + def __init__( self, api: "CensysSearchAPIv2", @@ -162,8 +165,9 @@ def __call__(self, per_page: Optional[int] = None) -> List[dict]: ) self.page += 1 result = payload["result"] + self.total = result["total"] self.nextCursor = result["links"].get("next") - if result["total"] == 0 or not self.nextCursor: + if self.total == 0 or not self.nextCursor: self.pages = 0 return result["hits"]