Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx committed Jun 18, 2017
1 parent a3da83d commit 10ee9a7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions mzitu.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ def make_dir(folder_name):
print(path)
os.chdir(path)
return True
else:
print("This folder have been created!")
return False
print("Folder has existed!")
return False


def delete_empty_dir(dir):
Expand All @@ -85,22 +84,19 @@ def delete_empty_dir(dir):
path = os.path.join(dir, d) # 组装下一级地址
if os.path.isdir(path):
delete_empty_dir(path) # 递归删除空文件夹

if not os.listdir(dir):
os.rmdir(dir)
print("remove the empty dir: {}".format(dir))
else:
print("Please start your performance!") # 请开始你的表演


if __name__ == "__main__":

urls = get_urls()
pool = Pool(processes=cpu_count())
try:
delete_empty_dir(dir_path)
results = pool.map(urls_crawler, urls)
pool.map(urls_crawler, urls)
except Exception as e:
time.sleep(30)
delete_empty_dir(dir_path)
results = pool.map(urls_crawler, urls)
pool.map(urls_crawler, urls)

0 comments on commit 10ee9a7

Please sign in to comment.