fix: 修改代理获取逻辑以使用新的 fetch_proxies2 函数并优化打印信息
This commit is contained in:
parent
e4ae20acb4
commit
8e0c99284b
1
DB.py
1
DB.py
@ -162,6 +162,7 @@ class DBVidcon:
|
||||
data.setdefault("a_id", 0)
|
||||
data.setdefault("history_status", "")
|
||||
data.setdefault("is_piracy", 3)
|
||||
data.setdefault("is_repeat", 3)
|
||||
data["sort"] = data.get("index", 0)
|
||||
|
||||
max_retries = 1 # 除了第一次外,再重试一次
|
||||
|
2
main.py
2
main.py
@ -569,7 +569,7 @@ def get_searchInfo(keyword):
|
||||
print('resinfo :', len(resinfo))
|
||||
except Exception:
|
||||
resinfo = []
|
||||
print(response.text)
|
||||
print("[搜索接口]", response.text)
|
||||
print("返回字段解析错误!")
|
||||
video_tasks = []
|
||||
for index, iteminfo in enumerate(resinfo):
|
||||
|
@ -31,6 +31,11 @@ SIGN = "10099426b05c7119e9c4dbd6a7a0aa4e"
|
||||
|
||||
db = DB.DBVidcon()
|
||||
|
||||
|
||||
def fetch_proxies2(region_code, n):
|
||||
return [("http://" + region_code.lower() + "-pr.thordata.net:25000") * n]
|
||||
|
||||
|
||||
def fetch_proxies(region_code, n):
|
||||
"""
|
||||
从第三方一次性请求 n 条代理,返回格式化列表
|
||||
@ -78,7 +83,7 @@ def refill_queue(r: redis.Redis, region_name: str, region_code: str,
|
||||
|
||||
to_fetch = batch - length
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {key} 长度 {length} < {low},一次性拉取 {to_fetch} 条…")
|
||||
proxies = fetch_proxies(region_code, to_fetch)
|
||||
proxies = fetch_proxies2(region_code, to_fetch)
|
||||
if proxies:
|
||||
r.rpush(key, *proxies)
|
||||
print(f"[{time.strftime('%H:%M:%S')}] 已入队 {len(proxies)} 条 → 新长度 {r.llen(key)}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user