نسخة تجريبية مجانية للوكيل
import requests
import colorama
from os import system

colorama.init(autoreset=True)
system("title Proxy-Scraper")

def fetch_proxies(url):
    response = requests.get(url)
    return response.text.splitlines()

def save_proxies(proxies, filename):
    with open(filename, "w") as file:
        for proxy in proxies:
            file.write(proxy + "\n")

def main():
    proxy_sources = {
        "https": "https://api.proxyscrape.com/?request=displayproxies&proxytype=https&timeout=7000&country=ALL&anonymity=elite&ssl=no",
        "http": "https://api.proxyscrape.com/?request=displayproxies&proxytype=http&timeout=7000&country=ALL&anonymity=elite&ssl=no",
        "socks4": "https://www.proxy-list.download/api/v1/get?type=socks4",
        "socks5": "https://www.proxy-list.download/api/v1/get?type=socks5",
    }

    proxies = {ptype: fetch_proxies(url) for ptype, url in proxy_sources.items()}
    
    for ptype, proxy_list in proxies.items():
        save_proxies(proxy_list, f"{ptype}.txt")
        for proxy in proxy_list:
            print(f"[{colorama.Fore.GREEN}+{colorama.Fore.RESET}] Successfully Found {ptype.upper()} >> {proxy}")
    
    print(f"[{colorama.Fore.CYAN}i{colorama.Fore.RESET}] All proxies successfully grabbed & saved")

if __name__ == "__main__":
    main()

06.06.2024

التحسينات:

  1. تبسيط منطق تحميل وحفظ الوكلاء.
  2. تمت إزالة المتغيرات والوظائف غير الضرورية.
  3. تم استخدام قاموس لتخزين عناوين URL وأنواع الوكيل، مما يؤدي إلى تحسين إمكانية القراءة وقابلية التوسع.
  4. العمليات المشتركة الموحدة في fetch_proxies و save_proxies وظائف للحد من ازدواجية التعليمات البرمجية.

التعليقات (0)

لا توجد تعليقات هنا حتى الآن، يمكنك أن تكون الأول!

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

اختر وشراء الوكيل

وكلاء مركز البيانات

وكلاء الدورية

وكلاء UDP

موثوق به من قبل أكثر من 10000 عميل حول العالم

العميل الوكيل
العميل الوكيل
وكيل العميلflowch.ai
العميل الوكيل
العميل الوكيل
العميل الوكيل