Skip to content

Commit

Permalink
chore: Added total parameter to the Query object
Browse files Browse the repository at this point in the history
  • Loading branch information
thehappydinoa committed Dec 16, 2024
1 parent 774628d commit 8f95e6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion censys/search/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]

Expand Down

0 comments on commit 8f95e6c

Please sign in to comment.