Download scoring.py from Archy-Welcomer/Proxy-Scraper: direct link, hf CLI and curl.
- Browser
- Download file 821 Bytes
-
https://huggingface.co/spaces/Archy-Welcomer/Proxy-Scraper/resolve/main/scoring.py
- Command line
-
hf download hf://spaces/Archy-Welcomer/Proxy-Scraper/scoring.py
-
curl -L -o scoring.py https://huggingface.co/spaces/Archy-Welcomer/Proxy-Scraper/resolve/main/scoring.py
821 Bytes
| import config | |
| def calculate_score(proxy_data: dict, domain: str = None) -> float: | |
| success_rate = float(proxy_data.get('success_rate', 0.0)) | |
| latency = float(proxy_data.get('latency', 9999.0)) | |
| # 0ms = 100, 1000ms = 50, 2000ms = 0 | |
| latency_score = max(0.0, 100.0 - (latency / 20.0)) | |
| domain_score = 50.0 | |
| if domain: | |
| key = (proxy_data.get('proxy', ''), domain) | |
| stats = config.store['domain_stats'].get(key) | |
| if stats: | |
| domain_score = float(stats.get('success_rate', 0.5)) * 100.0 | |
| base_score = ( | |
| latency_score * 0.50 + | |
| success_rate * 100.0 * 0.30 + | |
| domain_score * 0.20 | |
| ) | |
| usage_penalty = min(15.0, int(proxy_data.get('usage_count', 0)) / 10.0) | |
| return round(max(0.0, base_score - usage_penalty), 2) |