Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wfs_export
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yexing
wfs_export
Commits
29539169
Commit
29539169
authored
Jan 05, 2026
by
yexing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新代理IP
parent
8ca54d41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
src/walmart_sup.py
+16
-10
No files found.
src/walmart_sup.py
View file @
29539169
...
@@ -9,22 +9,28 @@ from curl_cffi.requests import AsyncSession, Response
...
@@ -9,22 +9,28 @@ from curl_cffi.requests import AsyncSession, Response
IS_DEBUG
=
int
(
os
.
environ
.
get
(
"IS_DEBUG"
,
False
))
IS_DEBUG
=
int
(
os
.
environ
.
get
(
"IS_DEBUG"
,
False
))
LOG_PATH
=
f
"./log/{Path(__file__).stem}.log"
LOG_PATH
=
f
"./log/{Path(__file__).stem}.log"
if
not
IS_DEBUG
:
if
not
IS_DEBUG
:
logger
.
remove
()
logger
.
remove
()
logger
.
add
(
LOG_PATH
,
level
=
"INFO"
,
rotation
=
"1 day"
,
retention
=
"1 months"
)
logger
.
add
(
LOG_PATH
,
level
=
"INFO"
,
rotation
=
"1 day"
,
retention
=
"1 months"
)
class
Subsidiary
:
class
Subsidiary
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_tasks
=
[]
self
.
_tasks
=
[]
self
.
s
=
AsyncSession
()
self
.
s
=
AsyncSession
()
self
.
r
:
redis
.
Redis
=
None
self
.
r
:
redis
.
Redis
=
None
async
def
connect
(
self
):
async
def
connect
(
self
):
if
self
.
r
is
None
:
if
self
.
r
is
None
:
self
.
r
=
redis
.
Redis
(
host
=
"localhost"
,
port
=
6380
,
db
=
0
)
self
.
r
=
redis
.
Redis
(
host
=
"localhost"
,
port
=
int
(
os
.
getenv
(
"REDIS_HOST"
,
6380
)),
password
=
os
.
getenv
(
"REDIS_PASSWORD"
),
db
=
0
,
)
if
await
self
.
r
.
ping
():
if
await
self
.
r
.
ping
():
logger
.
info
(
"redis 连接成功"
)
logger
.
info
(
"redis 连接成功"
)
async
def
bind
(
self
):
async
def
bind
(
self
):
while
True
:
while
True
:
try
:
try
:
...
@@ -34,7 +40,7 @@ class Subsidiary:
...
@@ -34,7 +40,7 @@ class Subsidiary:
await
asyncio
.
sleep
(
10
)
await
asyncio
.
sleep
(
10
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
warning
(
f
"绑定失败: {e}"
)
logger
.
warning
(
f
"绑定失败: {e}"
)
async
def
cache_ips
(
self
):
async
def
cache_ips
(
self
):
while
True
:
while
True
:
try
:
try
:
...
@@ -54,10 +60,9 @@ class Subsidiary:
...
@@ -54,10 +60,9 @@ class Subsidiary:
await
self
.
r
.
aclose
()
await
self
.
r
.
aclose
()
await
self
.
s
.
close
()
await
self
.
s
.
close
()
logger
.
info
(
"资源已回收"
)
logger
.
info
(
"资源已回收"
)
async
def
run_during_night
(
self
):
async
def
run_during_night
(
self
):
"""在晚上运行任务
"""在晚上运行任务"""
"""
while
True
:
while
True
:
now
=
datetime
.
now
()
.
time
()
now
=
datetime
.
now
()
.
time
()
if
time
(
22
,
0
)
>
now
and
now
>
time
(
7
,
0
):
if
time
(
22
,
0
)
>
now
and
now
>
time
(
7
,
0
):
...
@@ -67,12 +72,12 @@ class Subsidiary:
...
@@ -67,12 +72,12 @@ class Subsidiary:
logger
.
info
(
"不在指定时间范围内, 停止运行"
)
logger
.
info
(
"不在指定时间范围内, 停止运行"
)
break
break
await
asyncio
.
sleep
(
60
)
await
asyncio
.
sleep
(
60
)
async
def
run
(
self
,
monitor
:
bool
=
False
):
async
def
run
(
self
,
monitor
:
bool
=
False
):
try
:
try
:
await
self
.
connect
()
await
self
.
connect
()
self
.
_tasks
=
[
self
.
_tasks
=
[
asyncio
.
create_task
(
self
.
bind
()),
asyncio
.
create_task
(
self
.
bind
()),
asyncio
.
create_task
(
self
.
cache_ips
()),
asyncio
.
create_task
(
self
.
cache_ips
()),
]
]
if
monitor
:
if
monitor
:
...
@@ -86,6 +91,7 @@ class Subsidiary:
...
@@ -86,6 +91,7 @@ class Subsidiary:
finally
:
finally
:
await
self
.
close
()
await
self
.
close
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
loop
=
asyncio
.
get_event_loop
()
loop
=
asyncio
.
get_event_loop
()
if
IS_DEBUG
:
if
IS_DEBUG
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment