fix: 更新代理 API URL 和请求参数以适应新的接口
This commit is contained in:
parent
2c44e77664
commit
eb5f8bf1d0
@ -25,7 +25,7 @@ REFILL_BATCH = 1000
|
|||||||
SLEEP_INTERVAL = 10
|
SLEEP_INTERVAL = 10
|
||||||
|
|
||||||
# 第三方 API 参数
|
# 第三方 API 参数
|
||||||
PROXY_API_URL = "http://api.proxy.roxlabs.io/getProxyIp"
|
PROXY_API_URL = "https://www.kookeey.net/pickdynamicips"
|
||||||
ACCESS_ID = "2207189"
|
ACCESS_ID = "2207189"
|
||||||
SIGN = "10099426b05c7119e9c4dbd6a7a0aa4e"
|
SIGN = "10099426b05c7119e9c4dbd6a7a0aa4e"
|
||||||
|
|
||||||
@ -42,13 +42,14 @@ def fetch_proxies(region_code, n):
|
|||||||
从第三方一次性请求 n 条代理,返回格式化列表
|
从第三方一次性请求 n 条代理,返回格式化列表
|
||||||
"""
|
"""
|
||||||
params = {
|
params = {
|
||||||
"num": n,
|
"auth": "ip",
|
||||||
"return_type": "json",
|
"n": n,
|
||||||
"lb": "4",
|
"p": "http",
|
||||||
"sb": "",
|
"g": region_code,
|
||||||
"flow": "1",
|
"type": "json",
|
||||||
"regions": region_code,
|
"sign": SIGN,
|
||||||
"protocol": "http"
|
"accessid": ACCESS_ID,
|
||||||
|
"dl": ","
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
resp = requests.get(PROXY_API_URL, params=params, timeout=10)
|
resp = requests.get(PROXY_API_URL, params=params, timeout=10)
|
||||||
@ -84,7 +85,7 @@ def refill_queue(r: redis.Redis, region_name: str, region_code: str,
|
|||||||
|
|
||||||
to_fetch = batch - length
|
to_fetch = batch - length
|
||||||
print(f"[{time.strftime('%H:%M:%S')}] {key} 长度 {length} < {low},一次性拉取 {to_fetch} 条…")
|
print(f"[{time.strftime('%H:%M:%S')}] {key} 长度 {length} < {low},一次性拉取 {to_fetch} 条…")
|
||||||
proxies = fetch_proxies2(region_code, to_fetch)
|
proxies = fetch_proxies(region_code, to_fetch)
|
||||||
if proxies:
|
if proxies:
|
||||||
r.rpush(key, *proxies)
|
r.rpush(key, *proxies)
|
||||||
print(f"[{time.strftime('%H:%M:%S')}] 已入队 {len(proxies)} 条 → 新长度 {r.llen(key)}")
|
print(f"[{time.strftime('%H:%M:%S')}] 已入队 {len(proxies)} 条 → 新长度 {r.llen(key)}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user