Skip to content

Commit 552815c

Browse files
committed
Modernize dependency compatibility
1 parent f8d6301 commit 552815c

8 files changed

Lines changed: 295 additions & 243 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
files/*
2+
docs/superpowers/
23
.DS_Store
34
.idea/*
45
*/.idea/*
@@ -15,4 +16,4 @@ dist/
1516
media/
1617
.MWebMetaData/
1718
push.sh
18-
assets/
19+
assets/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ FirstSpider|2021-02-09 14:55:14,620|air_spider.py|run|line:80|INFO| 无任务,
112112

113113
### Rapidproxy代理
114114

115-
<!--5.3-->
115+
<!--6.7-->
116116

117117
<a href="https://www.rapidproxy.io/?ref=boris " target="_blank">
118118

@@ -133,7 +133,7 @@ FirstSpider|2021-02-09 14:55:14,620|air_spider.py|run|line:80|INFO| 无任务,
133133
### NovProxy
134134

135135
<!--5.24-->
136-
136+
g
137137
<a href="https://novproxy.com?kwd=tt-git" target="_blank">
138138

139139
<img src="https://markdown-media.oss-cn-beijing.aliyuncs.com/2026/04/24/mmexport1777023699277.jpg">

feapder/db/redisdb.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
---------
77
@author: Boris
88
"""
9-
import os
109
import time
1110
from typing import Union, List
1211

1312
import redis
13+
from redis.cluster import ClusterNode, RedisCluster
1414
from redis.connection import Encoder as _Encoder
1515
from redis.exceptions import ConnectionError, TimeoutError
1616
from redis.exceptions import DataError
@@ -140,29 +140,24 @@ def get_connect(self):
140140
startup_nodes = []
141141
for ip_port in ip_ports:
142142
ip, port = ip_port.split(":")
143-
startup_nodes.append({"host": ip, "port": port})
143+
startup_nodes.append(ClusterNode(ip, int(port)))
144144

145145
if self._service_name:
146146
# log.debug("使用redis哨兵模式")
147-
hosts = [(node["host"], node["port"]) for node in startup_nodes]
147+
hosts = [(node.host, node.port) for node in startup_nodes]
148148
sentinel = Sentinel(hosts, socket_timeout=3, **self._kwargs)
149149
self._redis = sentinel.master_for(
150150
self._service_name,
151151
password=self._user_pass,
152152
db=self._db,
153-
redis_class=redis.StrictRedis,
153+
redis_class=redis.Redis,
154154
decode_responses=self._decode_responses,
155155
max_connections=self._max_connections,
156156
**self._kwargs,
157157
)
158+
self._is_redis_cluster = False
158159

159160
else:
160-
try:
161-
from rediscluster import RedisCluster
162-
except ModuleNotFoundError as e:
163-
log.error('请安装 pip install "feapder[all]"')
164-
os._exit(0)
165-
166161
# log.debug("使用redis集群模式")
167162
self._redis = RedisCluster(
168163
startup_nodes=startup_nodes,
@@ -171,11 +166,10 @@ def get_connect(self):
171166
max_connections=self._max_connections,
172167
**self._kwargs,
173168
)
174-
175-
self._is_redis_cluster = True
169+
self._is_redis_cluster = True
176170
else:
177171
ip, port = ip_ports[0].split(":")
178-
self._redis = redis.StrictRedis(
172+
self._redis = redis.Redis(
179173
host=ip,
180174
port=port,
181175
db=self._db,
@@ -186,7 +180,7 @@ def get_connect(self):
186180
)
187181
self._is_redis_cluster = False
188182
else:
189-
self._redis = redis.StrictRedis.from_url(
183+
self._redis = redis.Redis.from_url(
190184
self._url, decode_responses=self._decode_responses, **self._kwargs
191185
)
192186
self._is_redis_cluster = False
@@ -573,7 +567,8 @@ def zexists(self, table, values):
573567

574568
if isinstance(values, list):
575569
pipe = self._redis.pipeline()
576-
pipe.multi()
570+
if not self._is_redis_cluster:
571+
pipe.multi()
577572
for value in values:
578573
pipe.zscore(table, value)
579574
is_exists_temp = pipe.execute()
@@ -773,7 +768,8 @@ def setbit(
773768
else:
774769
assert len(offsets) == len(values), "offsets值要与values值一一对应"
775770
pipe = self._redis.pipeline()
776-
pipe.multi()
771+
if not self._is_redis_cluster:
772+
pipe.multi()
777773

778774
for offset, value in zip(offsets, values):
779775
pipe.setbit(table, offset, value)
@@ -792,7 +788,8 @@ def getbit(self, table, offsets):
792788
"""
793789
if isinstance(offsets, list):
794790
pipe = self._redis.pipeline()
795-
pipe.multi()
791+
if not self._is_redis_cluster:
792+
pipe.multi()
796793
for offset in offsets:
797794
pipe.getbit(table, offset)
798795

feapder/network/proxy_pool_old.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_proxy_from_redis(proxy_source_url, **kwargs):
147147
@return: [{'http':'http://xxx.xxx.xxx:xxx', 'https':'http://xxx.xxx.xxx.xxx:xxx'}]
148148
"""
149149

150-
redis_conn = redis.StrictRedis.from_url(proxy_source_url)
150+
redis_conn = redis.Redis.from_url(proxy_source_url)
151151
key = kwargs.get("redis_proxies_key")
152152
assert key, "从redis中获取代理 需要指定 redis_proxies_key"
153153
proxies = redis_conn.zrange(key, 0, -1)

feapder/requirements.txt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
better-exceptions>=0.2.2
2-
DBUtils>=2.0
3-
parsel>=1.5.2
2+
DBUtils>=3.0
3+
parsel>=1.8.1
44
PyExecJS>=1.5.1
5-
pymongo>=3.10.1
6-
PyMySQL>=0.9.3
7-
redis>=2.10.6,<4.0.0
8-
requests>=2.22.0
9-
selenium>=3.141.0
10-
bs4>=0.0.1
11-
ipython>=7.14.0
12-
bitarray>=1.5.3
13-
redis-py-cluster>=2.1.0
14-
cryptography>=3.3.2
15-
urllib3>=1.25.8
5+
pymongo>=4.0.0
6+
PyMySQL>=1.1.0
7+
redis>=5.0.0,<9.0.0
8+
requests>=2.31.0
9+
selenium>=4.10.0
10+
beautifulsoup4>=4.12.0
11+
ipython>=8.0.0
12+
bitarray>=2.8.0
13+
cryptography>=41.0.0
14+
urllib3>=2.0.0,<3.0.0
1615
loguru>=0.5.3
1716
influxdb>=5.3.1
1817
pyperclip>=1.8.2
1918
webdriver-manager>=4.0.0
2019
terminal-layout>=2.1.3
21-
playwright
20+
playwright>=1.40.0

0 commit comments

Comments
 (0)