From 0c97d9f58e0ee1f779c564377e3639158a81394c Mon Sep 17 00:00:00 2001 From: wkyuu Date: Sat, 23 Apr 2022 21:49:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=9A=E5=AE=8C=E4=BA=86=E6=8D=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- milkSpider.py | 27 +++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 119b3c5..79d9ad2 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ selenium + redis + 分布式 + xpath + etree + 可视化 - [x] 从历史价格网页爬取历史价格 - [x] 加入Redis分布式设计 - [x] 数据可视化 - - [ ] 预计两种模式(终端交互):随机或取评价数为索引目标,给出取出的item的具体信息,例如价格趋势 - - [ ] 选择目录,友好的选择交互体验 - - [ ] 选择主要参考方式(价格,评论) + - [x] 预计两种模式(终端交互):随机或取评价数为索引目标,给出取出的item的具体信息,例如价格趋势 + - [x] 选择目录,友好的选择交互体验 + - [x] 选择主要参考方式(价格,评论) - [ ] python打包exe,需要图形化界面? ## project diff --git a/milkSpider.py b/milkSpider.py index e29bd7b..5eab9f9 100644 --- a/milkSpider.py +++ b/milkSpider.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- -import middlewares import time + +import middlewares import settings +import view def showBanner(menu = 'main'): @@ -12,7 +14,7 @@ def switch(menu = '1'): case = { '1' : main, '2' : introduce, - '3' : view, + '3' : View, '4' : middlewares.save2Redis, '5' : middlewares.clearRedis, '6' : milkSpider, @@ -24,28 +26,23 @@ def switch(menu = '1'): print("no such choice", end = '') return -def main(): - while True: - showBanner() - menu = str(input("选择一项:")) - switch(menu) - def introduce(): print(settings.BANNER.get('introduce'), end = '') while True: + print("请输入:", end = '') select = str(input()) if select == "r": return else: print("invaild choice!") -def view(): - print("this is view()") +def View(): + view.main() return def milkSpider(): - - print("注意:调用milkSpider将启动selenium以及requests进程,因为爬取数据量较大,\n往往会占用较多时间,确定吗?[c]continue or [q]quit:", end = '') + + print("注意:调用milkSpider将启动selenium以及requests进程,因为爬取数据量较大,往往会占用较多时间,确定吗?[c]continue or [q]quit:", end = '') flag = str(input()) if flag == "q": print("取消") @@ -62,6 +59,12 @@ def aexit(): print("bye!") exit() +def main(): + while True: + showBanner() + menu = str(input("选择一项:")) + switch(menu) + if __name__ == "__main__": # milkSpider() main()