parent
2eaeb7fd6b
commit
f1034e09d5
@ -0,0 +1,74 @@
|
||||
from look import *
|
||||
from register import *
|
||||
from spider_novel import *
|
||||
from spider_ranklist import *
|
||||
import webbrowser
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("请选择单个功能,如果多个,则是依次执行")
|
||||
print("有以下功能:1-小说内容爬取,2-排行榜数据爬取并实现可视化,3-模拟登录")
|
||||
choice_wait = list('123')
|
||||
operation_wait = ['小说内容爬取','排行榜数据爬取并实现可视化','模拟登录']
|
||||
dict_choice = dict(zip(choice_wait,operation_wait))
|
||||
flag = 0
|
||||
while not flag:
|
||||
choice_client = list(input('请输入功能编号:'))
|
||||
for choice_i in choice_client:
|
||||
if choice_i in choice_wait:
|
||||
print('功能'+dict_choice[choice_i]+'准备中')
|
||||
else:
|
||||
print('输入错误,请重新输入')
|
||||
flag = 0
|
||||
break
|
||||
flag = 1
|
||||
|
||||
#小说内容爬取
|
||||
if '1' in choice_client:
|
||||
print('小说内容爬取开启')
|
||||
print('---请稍等---')
|
||||
df_temp = pd.read_csv('end\\排名\\test.csv')#读取书名与小说id
|
||||
name_temp = df_temp['小说书名'].tolist()
|
||||
id_temp = df_temp['小说id'].tolist()
|
||||
#dict(zip)效果更好(?)
|
||||
while True:
|
||||
name_id = input('请输入 小说书名 或者 小说id:')
|
||||
if name_id in name_temp:
|
||||
id = id_temp[name_temp.index(name_id)]
|
||||
break
|
||||
elif name_id in id_temp:
|
||||
id = name_id
|
||||
break
|
||||
else:
|
||||
print('输入错误,请重新输入')
|
||||
print(f'正在爬取小说 {name_temp[id_temp.index(id)]} {id} 内容')
|
||||
url_queue_no = Queue()#用队列保证线程安全
|
||||
file_novel = 'end\\book\\'
|
||||
mkfile_novel(file_novel)
|
||||
print(id)
|
||||
print('开始爬取')
|
||||
spider_novel_start(str(id), url_queue_no,file_novel)
|
||||
|
||||
#排行榜数据爬取
|
||||
if '2' in choice_client:
|
||||
print('排行榜数据爬取')
|
||||
path_rank = 'end\\排名\\'
|
||||
mkfile_ranklist(path_rank)
|
||||
page_num = int(input('请输入爬取 1 ~ n 的页数 n:'))
|
||||
Queue_Spider_start(page_num)
|
||||
bar_markpoint_type().render(r'end\look.html')
|
||||
sleep(2)
|
||||
print('爬取完毕,可视化准备中')
|
||||
path = r'F:\scrapyer\end\look.html'
|
||||
webbrowser.open_new_tab('file://' + path)
|
||||
print('可视化准备完毕')
|
||||
sleep(60)
|
||||
|
||||
if '3' in choice_client:
|
||||
print('模拟登录开启')
|
||||
#模拟登录
|
||||
register_data_path = r'end\data'
|
||||
register_file(register_data_path)
|
||||
register_start()
|
||||
|
Loading…
Reference in new issue