Skip to content

Commit

Permalink
优化性能
Browse files Browse the repository at this point in the history
  • Loading branch information
zk-wz committed Feb 15, 2022
1 parent 41899ee commit 859ca6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bangumi_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def downloader(total_list,i):
with open(os.path.join(img_save_path,str(j)+'.jpg'), 'wb') as f:
# with open(img_save_path+'\\'+bangumi_name+'.jpg', 'wb') as f:
f.write(img.content)
print('番剧:“%s” 的封面下载完成!' % bangumi_name)
# print('番剧:“%s” 的封面下载完成!' % bangumi_name)

# for i in range(0,7):
# #获取图片直链列表
Expand Down Expand Up @@ -262,7 +262,7 @@ def multi_process_get_pic(total_list,tread_num,target):

#爬虫主函数
def bangumi_main():
t=time.time()
# t=time.time()
bangumi_content = get_link('https://bgm.tv/calendar')
total_list = parse_bangumi_calendar(bangumi_content)

Expand All @@ -277,7 +277,7 @@ def bangumi_main():
# downloader(total_list)
multi_process_get_pic(total_list,7,downloader)
# test(total_list)
print('爬取完成!耗时:'+str(time.time()-t)+'秒')
# print('爬取完成!耗时:'+str(time.time()-t)+'秒')


# if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions bilibili_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def downloader(total_list,i):
with open(os.path.join(img_save_path,str(j)+'.jpg'), 'wb') as f:
# with open(img_save_path+'\\'+bangumi_name+'.jpg', 'wb') as f:
f.write(img.content)
print('番剧:“%s” 的封面下载完成!' % bangumi_name)
# print('番剧:“%s” 的封面下载完成!' % bangumi_name)

def bilibili_main():
t=time.time()
# t=time.time()
bilibili_content=get_link('https://bangumi.bilibili.com/web_api/timeline_global').json()
week_bangumi_list=pre_handle_bilibili_calendar(bilibili_content)
total_list=parse_bilibili_calendar(week_bangumi_list)
Expand All @@ -113,7 +113,7 @@ def bilibili_main():

# print(total_list)
multi_process_get_pic(total_list,7,downloader)
print('爬取完成!耗时:%s' % (time.time()-t)+'秒')
# print('爬取完成!耗时:%s' % (time.time()-t)+'秒')


# if __name__ == '__main__':
Expand Down

0 comments on commit 859ca6e

Please sign in to comment.