1 Star 0 Fork 1

ramon/anomaly-detection-resources

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
download.py 880 Bytes
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/python
"""
This script will download all papers/books and rename to proper name
if there is no copyright issue.
TODO: download resources by item number
TODO: add exception handler for downloader
"""
import re
import pathlib
import urllib.request
# initialize the log directory if it does not exist
pathlib.Path('resources').mkdir(parents=True, exist_ok=True)
f = open('resource_urls\\papers.txt', 'r')
for line in f:
# print(line)
line_splits = line.split(' | ')
# remove all special char in file name
file_name = re.sub(r'[\\/*?:"<>|]', "", line_splits[0])
# strip filename length in case it is too long
if len(file_name) > 255:
file_name = file_name[:255]
url = line_splits[1]
print('Downloading', file_name, 'from', url)
urllib.request.urlretrieve(url, "resources\\" + file_name + '.pdf')
f.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ramon_lln/anomaly-detection-resources.git
git@gitee.com:ramon_lln/anomaly-detection-resources.git
ramon_lln
anomaly-detection-resources
anomaly-detection-resources
master

搜索帮助