Free Proxy Scraper

1.1.3 · active · verified Thu Apr 16

The `free-proxy` library (version 1.1.3) is a Python package designed to scrape, verify, and provide free working proxies from various online sources such as sslproxies.org, us-proxy.org, and free-proxy-list.net. It allows users to filter proxies by country, anonymity, HTTPS support, and define custom timeouts, making it useful for web scraping with libraries like `requests` or `Selenium`. The library is actively maintained with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

Initializes `FreeProxy` to get a working proxy. The first example fetches a random proxy and tests it with `requests`. The second example demonstrates fetching an HTTPS proxy specifically from the US or Brazil. Due to the nature of free proxies, reliability can vary, and retries may be necessary.

from fp.fp import FreeProxy
import requests
import os

# Get a random working proxy
proxy = FreeProxy(rand=True, timeout=1).get()

if proxy:
    print(f"Found working proxy: {proxy}")
    proxies = {
        "http": proxy,
        "https": proxy,
    }
    try:
        # Test the proxy with a simple request
        # Use a reliable target URL, e.g., ipify.org to check the proxy IP
        response = requests.get('https://api.ipify.org?format=json', proxies=proxies, timeout=5)
        if response.status_code == 200:
            print(f"Request through proxy successful. Your IP via proxy: {response.json()['ip']}")
        else:
            print(f"Request through proxy failed with status: {response.status_code}")
    except requests.exceptions.RequestException as e:
        print(f"Error making request through proxy: {e}")
else:
    print("No working proxies found at this time.")

# Example with specific country and HTTPS
# Note: Free proxies can be unreliable and may not always work as expected.
# You might need to run this multiple times or adjust parameters.
print("\nTrying to get an HTTPS proxy from US or BR...")
us_br_proxy = FreeProxy(country_id=['US', 'BR'], https=True, timeout=2, rand=True).get()
if us_br_proxy:
    print(f"Found US/BR HTTPS proxy: {us_br_proxy}")
else:
    print("No working US/BR HTTPS proxies found.")

view raw JSON →