This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# -*- coding: utf-8 -*-
importos
importtime
importmiddlewares
importsettings
importview
defshowBanner(menu='main'):
print(settings.BANNER.get(menu),end='')
defswitch(menu='1'):
case={
'1':main,
'2':introduce,
'3':View,
'4':middlewares.save2Redis,
'5':middlewares.clearRedis,
'6':milkSpider,
'7':aexit
}
ifmenuincase.keys():
case.get(menu)()
else:
print("no such choice",end='')
return
defintroduce():
print(settings.BANNER.get('introduce'),end='')
whileTrue:
print("请输入:",end='')
select=str(input())
ifselect=="r":
return
else:
print("invaild choice!")
defView():
view.main()
return
defmilkSpider():
dir='Catalogues'
ifos.path.exists(dir):
iflen(os.listdir(dir)):
print("检测到缓存目录下已有数据,调用milkSpider将有可能导致数据重复和冗余。")
print("注意:调用milkSpider将启动selenium以及requests进程,因为爬取数据量较大,往往会占用较多时间,确定吗?[c]continue or [q]quit:",end='')