Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
80cb5cb4
提交
80cb5cb4
authored
8月 25, 2023
作者:
丁双波
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
文件路径特殊字符处理
上级
36713e81
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
9 行删除
+17
-9
downPdf.py
tmp/usVsRussia/downPdf.py
+17
-9
没有找到文件。
tmp/usVsRussia/downPdf.py
浏览文件 @
80cb5cb4
...
...
@@ -61,6 +61,15 @@ def downFile(url,path):
log
.
error
(
f
"出错了----------{e}"
)
return
False
return
fileName
def
getPath
(
str
):
str
=
str
.
replace
(
':'
,
''
)
str
=
str
.
replace
(
': '
,
''
)
str
=
str
.
replace
(
' '
,
''
)
str
=
str
.
replace
(
'"'
,
''
)
str
=
str
.
replace
(
"'"
,
''
)
str
=
str
.
replace
(
"/"
,
''
)
return
str
if
__name__
==
'__main__'
:
while
True
:
selectSql
=
f
"select id,url,website,ftype,stype,ttype from usvsrussia where state=0 order by id asc limit 1"
...
...
@@ -76,14 +85,15 @@ if __name__ == '__main__':
path
=
r'D:\美国VS俄罗斯制裁'
log
.
info
(
f
"开始处理{url}----"
)
if
website
:
path
=
os
.
path
.
join
(
path
,
website
)
path
=
os
.
path
.
join
(
path
,
getPath
(
website
))
if
ftype
:
path
=
os
.
path
.
join
(
path
,
ftype
)
path
=
os
.
path
.
join
(
path
,
getPath
(
ftype
))
if
stype
:
path
=
os
.
path
.
join
(
path
,
stype
)
path
=
os
.
path
.
join
(
path
,
getPath
(
stype
)
)
if
ttype
:
path
=
os
.
path
.
join
(
path
,
ttype
)
path
=
os
.
path
.
join
(
path
,
getPath
(
ttype
))
fileName
=
downFile
(
url
,
path
)
if
fileName
:
updateSql
=
f
"update usvsrussia set state=1,pdf_name='{fileName}' ,pdf_path='{escape_string(path)}' where id={id}"
...
...
@@ -96,10 +106,7 @@ if __name__ == '__main__':
else
:
log
.
info
(
"数据处理完毕,程序退出"
)
break
url
=
'https://ofac.treasury.gov/media/931946/download?inline'
log
.
info
(
f
"{url}----开始下载"
)
downFile
(
url
)
log
.
info
(
f
"{url}----开始下载,下载完成"
)
baseCore
.
close
()
cursor
.
close
()
cnx
.
close
()
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论