Skip to content

Commit

Permalink
perf: 优化结果文件路径
Browse files Browse the repository at this point in the history
  • Loading branch information
dataabc committed Apr 7, 2020
1 parent d70b217 commit 12681bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions weibo/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class CsvPipeline(object):
def process_item(self, item, spider):
base_dir = 'result' + os.sep + item['keyword']
base_dir = '结果文件' + os.sep + item['keyword']
if not os.path.isdir(base_dir):
os.makedirs(base_dir)
file_path = base_dir + os.sep + item['keyword'] + '.csv'
Expand Down Expand Up @@ -65,7 +65,7 @@ def file_path(self, request, response=None, info=None):
image_url = request.url
item = request.meta['item']
sign = request.meta['sign']
base_dir = item['keyword']
base_dir = item['keyword'] + os.sep + 'images'
if not os.path.isdir(base_dir):
os.makedirs(base_dir)
image_suffix = image_url[image_url.rfind('.'):]
Expand All @@ -82,7 +82,7 @@ def get_media_requests(self, item, info):

def file_path(self, request, response=None, info=None):
item = request.meta['item']
base_dir = item['keyword']
base_dir = item['keyword'] + os.sep + 'videos'
if not os.path.isdir(base_dir):
os.makedirs(base_dir)
file_path = base_dir + os.sep + item['weibo']['id'] + '.mp4'
Expand Down
4 changes: 2 additions & 2 deletions weibo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
# 搜索的终止日期,为yyyy-mm-dd形式,搜索结果包含该日期
END_DATE = '2020-03-01'
# 图片文件存储路径
IMAGES_STORE = './下载文件/图片'
IMAGES_STORE = './结果文件'
# 视频文件存储路径
FILES_STORE = './下载文件/视频'
FILES_STORE = './结果文件'
# 配置MongoDB数据库
# MONGO_URI = 'localhost'
# 配置MySQL数据库,以下为默认配置,可以根据实际情况更改,程序会自动生成一个名为weibo的数据库,如果想换其它名字请更改MYSQL_DATABASE值
Expand Down

0 comments on commit 12681bb

Please sign in to comment.