free-proxy

repository·master·Indexed 18 days ago

https://github.com/jundymek/free-proxy

A Python utility that scrapes, validates, and provides free working proxies from sources such as sslproxies.org and free-proxy-list.net. It features the FreeProxy class for proxy retrieval with support for filtering by country, anonymity level, HTTPS, and custom timeouts.

Tokens
905
Snippets
4
Records
5
Agent score
14%

What's inside free-proxy

  1. Configure FreeProxy with filtering and timeout options

    master

    You can customize the proxy retrieval by passing several parameters to the FreeProxy constructor:

    • country_id (list): Filter by country codes (e.g., ['US', 'BR']). Setting ['US'] or ['GB'] targets specific sources like us-proxy.org or free-proxy-list.net/uk-proxy.html.
    • timeout (float): The timeout in seconds used to check if an individual proxy is valid. Default is 0.5.
    • rand (bool): If True, shuffles the scraped proxy list instead of using the default order. Default is False.
    • anonym (bool): If True, returns only anonymous proxies. Default is False.
    • elite (bool): If True, returns only 'elite' proxies (which are always anonymous). Default is False.
    • google (bool/None): If True, returns only proxies marked as "google". If False, excludes them. Default is None (returns all).
    • https (bool): If True, returns only HTTPS proxies. Default is False.
    • url (str): The URL used to test the proxy. Defaults to google.com.
    • request_timeout (float): The timeout in seconds for downloading the proxy list from the source websites. Default is 10.
    # Example: Get a random, anonymous, US-based HTTPS proxy with a 1s validation timeout
    proxy = FreeProxy(country_id=['US'], timeout=1, rand=True, anonym=True, https=True).get()
    
    # Example: Test against a custom URL with a specific download timeout
    proxy = FreeProxy(url='http://httpbin.org/get', request_timeout=5).get()
  2. Use the FreeProxy class to get a working proxy

    master

    The FreeProxy class scrapes proxies from multiple sources (sslproxies.org, us-proxy.org, and free-proxy-list.net) and validates them. The .get() method returns a working proxy as a string (e.g., 'http://113.160.218.14:8888').

    If no working proxies are found with your specified parameters, the library raises a FreeProxyException with the message: There are no working proxies at this time.

    from fp.fp import FreeProxy
    
    # Get the first working proxy using default settings
    proxy = FreeProxy().get()
  3. Reference: FreeProxy constructor parameters

    master

    The following parameters are available for the FreeProxy class constructor:

    | Parameter | Type | Example | Default value |
    | ---------- | --------- | ------------ | ------------ |
    | country_id | list | ['US', 'BR'] | None |
    | timeout | float > 0 | 0.1 | 0.5 |
    | rand | bool | True | False |
    | anonym | bool | True | False |
    | elite | bool | True | False |
    | google | bool,None | False | None |
    | https | bool | True | False |
    | url | str | '' | google.com |
    | request_timeout | float > 0 | 5 | 10 |