|
| 1 | +from domaintools import API |
| 2 | + |
| 3 | + |
| 4 | +dt_api = API(USER_NAME, KEY) |
| 5 | +domains = "int-chase.com, google.com" |
| 6 | + |
| 7 | + |
| 8 | +def sample_filter_by_risk_score(): |
| 9 | + """ |
| 10 | + Sample code snippet on how to use the output filtering by a given riskscore |
| 11 | + """ |
| 12 | + response = dt_api.iris_investigate(domains=domains, risk_score=68) |
| 13 | + output_domains = [ |
| 14 | + (result.get("domain"), result.get("domain_risk", {}).get("risk_score")) |
| 15 | + for result in response.get("results") or [] |
| 16 | + ] |
| 17 | + # this will output [('int-chase.com', 71)], assuming that this domain has a >= to the given riskscore |
| 18 | + print(f"Filter by `risk_score` result: {output_domains}") |
| 19 | + |
| 20 | + |
| 21 | +def sample_filter_by_younger_than_date(): |
| 22 | + """ |
| 23 | + Sample code snippet on how to use the output filtering by younger_than_date. |
| 24 | + The field being used in this filter is the `expiration_date`. |
| 25 | + """ |
| 26 | + response = dt_api.iris_investigate(domains=domains, younger_than_date="2024-02-24") |
| 27 | + |
| 28 | + output_domains = [ |
| 29 | + (result.get("domain"), result.get("expiration_date")) |
| 30 | + for result in response.get("results") or [] |
| 31 | + ] |
| 32 | + # this will output [('google.com', {'value': '2028-09-14', 'count': 9972})], |
| 33 | + # assuming that this domain has a expiration_date <= to the given date. |
| 34 | + print(f"Filter by `younger_than_date` result: {output_domains}") |
| 35 | + |
| 36 | + |
| 37 | +def sample_filter_by_older_than_date(): |
| 38 | + """ |
| 39 | + Sample code snippet on how to use the output filtering by older_than_date. |
| 40 | + The field being used in this filter is the `expiration_date`. |
| 41 | + """ |
| 42 | + response = dt_api.iris_investigate(domains=domains, older_than_date="2024-02-24") |
| 43 | + |
| 44 | + output_domains = [ |
| 45 | + (result.get("domain"), result.get("expiration_date")) |
| 46 | + for result in response.get("results") or [] |
| 47 | + ] |
| 48 | + # this will output [('int-chase.com', {'value': '2021-10-13', 'count': 118259})], |
| 49 | + # assuming that this domain has a expiration_date <= to the given date. |
| 50 | + print(f"Filter by `older_than_date` result: {output_domains}") |
| 51 | + |
| 52 | + |
| 53 | +def sample_filter_by_updated_after(): |
| 54 | + """ |
| 55 | + Sample code snippet on how to use the output filtering by updated_after. |
| 56 | + The field being used in this filter is the `data_updated_timestamp`. |
| 57 | + """ |
| 58 | + response = dt_api.iris_investigate(domains=domains, updated_after="2024-02-24") |
| 59 | + |
| 60 | + output_domains = [ |
| 61 | + (result.get("domain"), result.get("data_updated_timestamp")) |
| 62 | + for result in response.get("results") or [] |
| 63 | + ] |
| 64 | + # this will output [('google.com', {'value': '2028-09-14', 'count': 9972})], |
| 65 | + # assuming that this domain has a data_updated_timestamp >= to the given `updated_after` date. |
| 66 | + print(f"Filter by `updated_after` result: {output_domains}") |
| 67 | + |
| 68 | + |
| 69 | +def sample_filter_by_include_domains_with_missing_field(): |
| 70 | + """ |
| 71 | + Sample code snippet on how to use the output filtering to include |
| 72 | + the domain even the given field is missing or empty in the result set. |
| 73 | + """ |
| 74 | + response = dt_api.iris_investigate( |
| 75 | + domains=domains, include_domains_with_missing_field="popularity_rank" |
| 76 | + ) |
| 77 | + |
| 78 | + # this will output [('google.com', 1), ('int-chase.com', '')] |
| 79 | + output_domains = [ |
| 80 | + (result.get("domain"), result.get("popularity_rank")) |
| 81 | + for result in response.get("results") or [] |
| 82 | + ] |
| 83 | + print(f"Filter by `include_domains_with_missing_field` result: {output_domains}") |
| 84 | + |
| 85 | + |
| 86 | +def sample_filter_by_exclude_domains_with_missing_field(): |
| 87 | + """ |
| 88 | + Sample code snippet on how to use the output filtering to exclude |
| 89 | + the domain even the given field is missing or empty in the result set. |
| 90 | + """ |
| 91 | + response = dt_api.iris_investigate( |
| 92 | + domains=domains, exclude_domains_with_missing_field="popularity_rank" |
| 93 | + ) |
| 94 | + |
| 95 | + # this will only output [('google.com', 1)] as the popularity rank in other domain is missing/empty |
| 96 | + output_domains = [ |
| 97 | + (result.get("domain"), result.get("popularity_rank")) |
| 98 | + for result in response.get("results") or [] |
| 99 | + ] |
| 100 | + print(f"Filter by `exclude_domains_with_missing_field` result: {output_domains}") |
| 101 | + |
| 102 | + |
| 103 | +sample_filter_by_risk_score() |
| 104 | +sample_filter_by_younger_than_date() |
| 105 | +sample_filter_by_older_than_date() |
| 106 | +sample_filter_by_updated_after() |
| 107 | +sample_filter_by_include_domains_with_missing_field() |
| 108 | +sample_filter_by_exclude_domains_with_missing_field() |
0 commit comments