ホーム / ユースケース / ローテーションプロキシ
無料ローテーションプロキシプール
ローテーションプロキシは各リクエストを別 IP から送ります。有料サービスは不要 — 毎時検証の無料一覧から自分のプールを構築できます。
ローテーションのパターン
3 つの部分:検証済みプールを読み込み、呼び出しごとに次のプロキシへローテーションし、タイマーでプールを更新して死んだプロキシを入れ替えます。
import itertools, time, requests
LIST = "https://raw.githubusercontent.com/xyzs996/free-proxy-health-list/main/proxies/all/data.json"
def load_pool():
data = requests.get(LIST, timeout=15).json()
def to_url(p):
proto, hp = p["protocol"], p["proxy"]
if proto.startswith("socks5"): return f"socks5h://{hp}"
if proto.startswith("socks4"): return f"socks4://{hp}"
return f"http://{hp}"
return [to_url(p) for p in data]
pool = load_pool()
cycle = itertools.cycle(pool)
refreshed = time.time()
def get(url, tries=10):
global pool, cycle, refreshed
if time.time() - refreshed > 1800:
pool = load_pool(); cycle = itertools.cycle(pool); refreshed = time.time()
for _ in range(tries):
px = next(cycle)
try:
r = requests.get(url, proxies={"http": px, "https": px}, timeout=8)
if r.ok: return r
except requests.RequestException:
continue
raise RuntimeError("no working proxy this round")
print(get("https://httpbin.org/ip").json())
プールを健全に保つコツ
ヒット率を上げるため fast や top-1000 の部分集合から始め、2 回連続で失敗したプロキシは捨て、成功率が下がったら更新頻度を上げます。一覧は毎時再検証されます。
よくある質問
無料でローテーションプロキシを作れますか?
はい — 検証済み一覧をローテーションし失敗時に次を試すだけ。ローテーション+リトライが無料プロキシを使える鍵です。
プールはどのくらいで更新?
15〜60 分ごと。ソース一覧は毎時チェックされます。
いつ有料にすべき?
SLA 付きの安定したローテーション URL が必要なら Pro API を。