|
10 | 10 |
|
11 | 11 | Verbose = True |
12 | 12 |
|
| 13 | +NONESTRINGS: List = [ |
| 14 | + "the domain has not been registered", |
| 15 | + "no match found for", |
| 16 | + "no matching record", |
| 17 | + "not found", |
| 18 | + "no data found", |
| 19 | + "no entries found", |
| 20 | + "status: free", |
| 21 | + "no such domain", |
| 22 | + "the queried object does not exist", |
| 23 | + "domain you requested is not known", |
| 24 | + "status: available", |
| 25 | + "no whois server is known for this kind of object", |
| 26 | + "nameserver not found", |
| 27 | + "malformed request", # this means this domain is not in whois as it is on top of a registered domain |
| 28 | + "no match", |
| 29 | + "registration of this domain is restricted", |
| 30 | + "restricted", |
| 31 | + "this domain is currently available" |
| 32 | +] |
| 33 | + |
| 34 | +QUOTASTRINGS = [ |
| 35 | + "limit exceeded", |
| 36 | + "quota exceeded", |
| 37 | + "try again later", |
| 38 | + "please try again", |
| 39 | + "exceeded the maximum allowable number", |
| 40 | + "can temporarily not be answered", |
| 41 | + "please try again.", |
| 42 | + "queried interval is too short", |
| 43 | + "number of allowed queries exceeded", |
| 44 | +] |
| 45 | + |
| 46 | + |
| 47 | +def NoneStrings() -> List: |
| 48 | + return sorted(NONESTRINGS) |
| 49 | + |
| 50 | + |
| 51 | +def NoneStringsAdd(aString: str): |
| 52 | + if aString and isinstance(aString, str) and len(aString) > 0: |
| 53 | + NONESTRINGS.append(aString) |
| 54 | + |
| 55 | + |
| 56 | +def QuotaStrings() -> List: |
| 57 | + return sorted(QUOTASTRINGS) |
| 58 | + |
| 59 | + |
| 60 | +def QuotaStringsAdd(aString: str): |
| 61 | + if aString and isinstance(aString, str) and len(aString) > 0: |
| 62 | + NONESTRINGS.append(aString) |
| 63 | + |
13 | 64 |
|
14 | 65 | def cleanupWhoisResponse( |
15 | 66 | whois_str: str, |
@@ -85,54 +136,24 @@ def handleShortResponse( |
85 | 136 |
|
86 | 137 | # NOTE: from here s is lowercase only |
87 | 138 | # --------------------------------- |
88 | | - noneStrings = [ |
89 | | - "the domain has not been registered", |
90 | | - "no match found for", |
91 | | - "no matching record", |
92 | | - "not found", |
93 | | - "no data found", |
94 | | - "no entries found", |
95 | | - "status: free", |
96 | | - "no such domain", |
97 | | - "the queried object does not exist", |
98 | | - "domain you requested is not known", |
99 | | - "status: available", |
100 | | - "no whois server is known for this kind of object", |
101 | | - "nameserver not found", |
102 | | - "malformed request", # this means this domain is not in whois as it is on top of a registered domain |
103 | | - "no match", |
104 | | - "registration of this domain is restricted", |
105 | | - ] |
106 | | - |
| 139 | + noneStrings = NoneStrings() |
107 | 140 | for i in noneStrings: |
108 | 141 | if i in s: |
109 | 142 | return None |
110 | 143 |
|
111 | 144 | # --------------------------------- |
112 | 145 | # is there any error string in the result |
113 | 146 | if s.count("error"): |
| 147 | + if verbose: |
| 148 | + print("i see 'error' in the result, return: None", file=sys.stderr) |
114 | 149 | return None |
115 | 150 |
|
116 | 151 | # --------------------------------- |
117 | | - quotaStrings = [ |
118 | | - "limit exceeded", |
119 | | - "quota exceeded", |
120 | | - "try again later", |
121 | | - "please try again", |
122 | | - "exceeded the maximum allowable number", |
123 | | - "can temporarily not be answered", |
124 | | - "please try again.", |
125 | | - "queried interval is too short", |
126 | | - ] |
127 | | - |
| 152 | + quotaStrings = QuotaStrings() |
128 | 153 | for i in quotaStrings: |
129 | 154 | if i in s: |
130 | 155 | raise WhoisQuotaExceeded(whois_str) |
131 | 156 |
|
132 | | - # --------------------------------- |
133 | | - # ToDo: Name or service not known |
134 | | - |
135 | | - # --------------------------------- |
136 | 157 | raise FailedParsingWhoisOutput(whois_str) |
137 | 158 |
|
138 | 159 |
|
|
0 commit comments