(self, domain)
| 88 | ) |
| 89 | |
| 90 | async def query(self, domain): |
| 91 | url = self.base_url |
| 92 | json = { |
| 93 | "query": "", |
| 94 | "page": 1, |
| 95 | "size": 10000, # The maximum permitted size and pagination. |
| 96 | } |
| 97 | json["query"] = f"domain:{domain}" |
| 98 | json["page"] = 1 |
| 99 | max_pages = 1 |
| 100 | agen = self.api_page_iter(url=url, headers=self.headers, _json=False, method="POST", json=json) |
| 101 | async for result in agen: |
| 102 | result_json = {} |
| 103 | with suppress(Exception): |
| 104 | result_json = result.json() |
| 105 | total = result_json.get("total", 0) |
| 106 | entries = result_json.get("entries", []) |
| 107 | json["page"] += 1 |
| 108 | if result is not None and result.status_code != 200: |
| 109 | self.warning( |
| 110 | f"Error retrieving results from dehashed.com (status code {result.status_code}): {result.text}" |
| 111 | ) |
| 112 | elif (json["page"] > max_pages) and (total > (json["size"] * max_pages)): |
| 113 | self.info( |
| 114 | f"{domain} has {total:,} results in Dehashed. The API can only process the first 10,000 results. Please check dehashed.com to get the remaining results." |
| 115 | ) |
| 116 | if entries: |
| 117 | yield entries |
| 118 | if not entries or json["page"] > max_pages: |
| 119 | await agen.aclose() |
| 120 | break |
no test coverage detected