(self)
| 21 | self.proxy_ip = proxy_ip |
| 22 | |
| 23 | def should_validate(self) -> bool: |
| 24 | if self.proxy_ip.attempts == 0: |
| 25 | return True |
| 26 | elif self.proxy_ip.attempts < 3 \ |
| 27 | and datetime.now() - self.proxy_ip.created_at < timedelta(hours=24) \ |
| 28 | and not self.proxy_ip.is_valid: |
| 29 | # If the proxy is created within 24 hours, the maximum attempt count is 3 |
| 30 | return True |
| 31 | elif timedelta(hours=48) > datetime.now() - self.proxy_ip.created_at > timedelta(hours=24) \ |
| 32 | and self.proxy_ip.attempts < 6: |
| 33 | # The proxy will be validated up to 6 times with in 48 hours after 24 hours |
| 34 | return True |
| 35 | elif datetime.now() - self.proxy_ip.created_at < timedelta(days=7) \ |
| 36 | and self.proxy_ip.attempts < 21 \ |
| 37 | and self.proxy_ip.is_valid: |
| 38 | # After 48 hours the proxy is created, the proxy will be validated up to |
| 39 | # 21 times (3 times a day on average) if it is valid within 7 days. |
| 40 | return True |
| 41 | # By default, return False |
| 42 | return False |
| 43 | |
| 44 | def should_try_https(self) -> bool: |
| 45 | if self.proxy_ip.is_valid and self.proxy_ip.attempts < 3 \ |
no outgoing calls