Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spider
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
selection-new
spider
Commits
0040e69f
Commit
0040e69f
authored
Dec 12, 2025
by
Peng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
fa8ab9c2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
12 deletions
+30
-12
all_connect.py
...s/picture_material/stock_summery/new_stock/all_connect.py
+16
-7
download_pic.py
.../picture_material/stock_summery/new_stock/download_pic.py
+4
-0
upload_pic.py
...ts/picture_material/stock_summery/new_stock/upload_pic.py
+0
-0
xnj_url.py
...jects/picture_material/stock_summery/new_stock/xnj_url.py
+10
-5
No files found.
wangjing_projects/projects/picture_material/stock_summery/new_stock/all_connect.py
View file @
0040e69f
...
@@ -173,7 +173,7 @@ class ConnectSpider:
...
@@ -173,7 +173,7 @@ class ConnectSpider:
try
:
try
:
table_name
=
"stock_image_summary_wj"
table_name
=
"stock_image_summary_wj"
# 修改查询语句以匹配你的数据表名称和列名称
# 修改查询语句以匹配你的数据表名称和列名称
query
=
f
"""SELECT account_id,account_secret FROM {table_name} where id = {item_id}
and state= 1;
"""
query
=
f
"""SELECT account_id,account_secret FROM {table_name} where id = {item_id}"""
print
(
query
)
print
(
query
)
df_status
=
self
.
db_engine192
.
read_sql
(
query
)
df_status
=
self
.
db_engine192
.
read_sql
(
query
)
if
len
(
df_status
)
>
0
:
if
len
(
df_status
)
>
0
:
...
@@ -191,8 +191,8 @@ class ConnectSpider:
...
@@ -191,8 +191,8 @@ class ConnectSpider:
def
get_all_image_id
(
self
):
def
get_all_image_id
(
self
):
for
i
in
range
(
5
):
for
i
in
range
(
5
):
try
:
try
:
table_name
=
"stock_image_detail_wj"
table_name
=
"stock_image_detail_wj"
# 全部下载完成之后删除这个条件
sql_query
=
f
"SELECT image_id FROM {table_name} "
sql_query
=
f
"SELECT image_id FROM {table_name}
where created_time>'2025-12-12'
"
df_status
=
self
.
db_engine192
.
read_sql
(
sql_query
)
df_status
=
self
.
db_engine192
.
read_sql
(
sql_query
)
image_id
=
list
(
df_status
[
'image_id'
]
.
astype
(
str
))
image_id
=
list
(
df_status
[
'image_id'
]
.
astype
(
str
))
return
image_id
return
image_id
...
@@ -205,7 +205,8 @@ class ConnectSpider:
...
@@ -205,7 +205,8 @@ class ConnectSpider:
try
:
try
:
with
self
.
db_engine192
.
begin
()
as
connection
:
with
self
.
db_engine192
.
begin
()
as
connection
:
table_name
=
"stock_image_detail_wj"
table_name
=
"stock_image_detail_wj"
sql_update
=
f
"UPDATE {table_name} SET state = 3 WHERE image_id ='{image_id}' and state = 1"
sql_update
=
f
"UPDATE {table_name} SET state = 3 WHERE image_id ='{image_id}' and state = 2"
print
(
sql_update
,
'234343434343434343434343434'
)
connection
.
execute
(
sql_update
)
connection
.
execute
(
sql_update
)
break
break
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -215,9 +216,16 @@ class ConnectSpider:
...
@@ -215,9 +216,16 @@ class ConnectSpider:
def
get_pic_urls
(
self
,
account_id
):
def
get_pic_urls
(
self
,
account_id
):
pic_data_list
=
[]
# 创建一个空列表来存储结果
pic_data_list
=
[]
# 创建一个空列表来存储结果
table_name
=
"stock_image_detail_wj"
table_name
=
"stock_image_detail_wj"
query
=
f
"""select image_url, image_id, image_title from {table_name} where account_id = '{account_id}' and state = 1"""
query
=
f
"""select image_url, image_id, image_title,id from {table_name} where account_id = '{account_id}' and state = 1"""
print
(
'== query::'
,
query
)
try
:
try
:
result_df
=
self
.
db_engine192
.
read_sql
(
query
)
# result_df = self.db_engine192.read_sql(query)
result_df
=
self
.
db_engine192
.
read_then_update
(
select_sql
=
query
,
update_table
=
table_name
,
set_values
=
{
"state"
:
2
},
# 把库存清零
where_keys
=
[
"id"
],
# WHERE sku = :sku
)
# print(result_df)
# print(result_df)
result_list
=
result_df
.
values
.
tolist
()
result_list
=
result_df
.
values
.
tolist
()
for
row
in
result_list
:
# 遍历所有的结果行
for
row
in
result_list
:
# 遍历所有的结果行
...
@@ -239,4 +247,5 @@ class ConnectSpider:
...
@@ -239,4 +247,5 @@ class ConnectSpider:
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
ConnectSpider
()
.
get_cookie_account
(
10
)
# UPDATE stock_image_detail_wj SET state = 3 WHERE image_id ='2668613199' and state = 1
ConnectSpider
()
.
get_pic_urls
(
'xiezhihao@yswg.com.cn'
)
wangjing_projects/projects/picture_material/stock_summery/new_stock/download_pic.py
View file @
0040e69f
...
@@ -68,7 +68,11 @@ class Download():
...
@@ -68,7 +68,11 @@ class Download():
else
:
else
:
# 不包含中文时,按照原策略处理,但总长不超过160字符
# 不包含中文时,按照原策略处理,但总长不超过160字符
pic_name
=
re
.
sub
(
r'[\\/*?:"<>|]'
,
'_'
,
pic_name
)[:
160
]
+
'.jpg'
pic_name
=
re
.
sub
(
r'[\\/*?:"<>|]'
,
'_'
,
pic_name
)[:
160
]
+
'.jpg'
print
(
'image_url:'
,
image_url
)
res
=
requests
.
get
(
image_url
,
timeout
=
600
)
res
=
requests
.
get
(
image_url
,
timeout
=
600
)
content_type
=
res
.
headers
.
get
(
"Content-Type"
,
""
)
print
(
'content_type: 查看返回的类型:'
,
content_type
)
# 构建完整的文件路径
# 构建完整的文件路径
file_path
=
os
.
path
.
join
(
save_folder
,
pic_name
)
file_path
=
os
.
path
.
join
(
save_folder
,
pic_name
)
self
.
download_image
(
file_path
,
res
)
self
.
download_image
(
file_path
,
res
)
...
...
wangjing_projects/projects/picture_material/stock_summery/new_stock/upload_pic.py
View file @
0040e69f
This diff is collapsed.
Click to expand it.
wangjing_projects/projects/picture_material/stock_summery/new_stock/xnj_url.py
View file @
0040e69f
...
@@ -435,9 +435,13 @@ class GetSS_details():
...
@@ -435,9 +435,13 @@ class GetSS_details():
sleep
(
randint
(
2
,
4
))
sleep
(
randint
(
2
,
4
))
# 查找并输入密码
# 查找并输入密码
print
(
"正在等待密码输入框..."
)
print
(
"正在等待密码输入框..."
)
# placeholder="密码"
email_input
=
iframe
.
ele
(
# MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputSizeSmall MuiInputBase-inputAdornedEnd css-18zhmu4
'.MuiInputBase-input MuiInput-input MuiInputBase-inputSizeSmall MuiInputBase-inputAdornedEnd css-186x7cf'
)
try
:
email_input
=
iframe
.
ele
(
'xpath://input[@placeholder="密码"]'
)
except
:
email_input
=
iframe
.
ele
(
'.MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputSizeSmall MuiInputBase-inputAdornedEnd css-18zhmu4'
)
email_input
.
clear
()
# 清除任何预填充的内容
email_input
.
clear
()
# 清除任何预填充的内容
email_input
.
input
(
self
.
pwd
)
email_input
.
input
(
self
.
pwd
)
print
(
"已输入密码到密码输入框"
)
print
(
"已输入密码到密码输入框"
)
...
@@ -509,7 +513,7 @@ class GetSS_details():
...
@@ -509,7 +513,7 @@ class GetSS_details():
}
}
try
:
try
:
response
=
requests
.
post
(
url
,
data
=
data_json
,
headers
=
headers
)
response
=
requests
.
post
(
url
,
data
=
data_json
,
headers
=
headers
,
timeout
=
120
)
if
response
.
status_code
==
200
:
if
response
.
status_code
==
200
:
return
response
.
json
()
return
response
.
json
()
else
:
else
:
...
@@ -564,6 +568,7 @@ class GetSS_details():
...
@@ -564,6 +568,7 @@ class GetSS_details():
}
}
response
=
requests
.
post
(
'https://www.shutterstock.com/napi/licensees/current/redownload'
,
cookies
=
cookie
,
response
=
requests
.
post
(
'https://www.shutterstock.com/napi/licensees/current/redownload'
,
cookies
=
cookie
,
headers
=
self
.
headers
,
json
=
json_data
,
timeout
=
600
)
headers
=
self
.
headers
,
json
=
json_data
,
timeout
=
600
)
print
(
'下载返回:'
,
response
.
text
)
image_url
=
json
.
loads
(
response
.
text
)[
'meta'
][
'licensedContent'
][
0
][
'downloadUrl'
]
image_url
=
json
.
loads
(
response
.
text
)[
'meta'
][
'licensedContent'
][
0
][
'downloadUrl'
]
return
image_url
return
image_url
...
@@ -575,7 +580,7 @@ class GetSS_details():
...
@@ -575,7 +580,7 @@ class GetSS_details():
try
:
try
:
start_time
=
datetime
.
now
()
.
strftime
(
"
%
m-
%
d
%
H:
%
M:
%
S"
)
start_time
=
datetime
.
now
()
.
strftime
(
"
%
m-
%
d
%
H:
%
M:
%
S"
)
all_image_id
=
Con
.
get_all_image_id
()
all_image_id
=
Con
.
get_all_image_id
()
# 12月的重新上传。先注释
if
str
(
image_id
)
in
set
(
all_image_id
):
if
str
(
image_id
)
in
set
(
all_image_id
):
print
(
f
'{image_id}已上传过'
)
print
(
f
'{image_id}已上传过'
)
state
=
3
state
=
3
...
...
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