< 1:tk.messagebox.showinfo(title='提示', message='请输入正确的序号')returnelse:add_ls.append(self.goodsinfo[eval(num) - 1])except:tk.messagebox.showinfo(title='提示', message='请输入正确的序号')returndbc = DBConnection()result = ''for item in add_ls:if dbc.save(item):result = result + '\"' + item.getTitle() + '\" 已成功加入关注列表\n'else:result = result + '\"' + item.getTitle() + '\" 已在关注列表中\n'tk.messagebox.showinfo(title='提示', message=result)#显示关注列表def showDB(self):self.comfirm3.config(text='移除关注', command=self.delete)self.goodsinfo = []dbc = DBConnection()g_ls = dbc.getInfo()for item in g_ls:goods = Goods(item[0],item[1],item[2],item[3],item[4],item[5],item[6])self.goodsinfo.append(goods)for item in self.tree.get_children():self.tree.delete(item)if not self.goodsinfo:tk.messagebox.showinfo(title = '提示',message = '当前关注列表无商品')returnelse:num = 1for goods in self.goodsinfo:li = [num,goods.getID(),goods.getPlatform(),goods.getTitle(),goods.getShop(),goods.getPrice(),goods.getSales(),goods.getHref()]self.tree.insert('','end',values =li)num = num+1#更新关注列表内容def updateDB(self):change_ls = []dbc = DBConnection()self.goodsinfo = []g_ls = dbc.getInfo()for item in g_ls:goods = Goods(item[0], item[1], item[2], item[3], item[4], item[5], item[6])self.goodsinfo.append(goods)for item in self.goodsinfo:change = item.update()if change != 0:change_ls.append([item.getTitle(),change])if change_ls:s = ''for item in change_ls:if item[1]>0:s = s + '\"' + item[0] + '\" 价格增加了 ' + str(item[1]) + ' 元\n'else:s = s + '\"' + item[0] + '\" 价格降低了 ' + str(abs(item[1])) + ' 元\n'else:s = '关注列表中所有商品价格均无变动'tk.messagebox.showinfo(title='提示', message=s)#从关注列表删除def delete(self):num_ls = self.num_var.get().split(' ')num_ls = list(set(num_ls))delete_ls = []for num in num_ls:if num == '':continuetry:if not isinstance(eval(num), int):tk.messagebox.showinfo(title='提示', message='请输入正确的序号')returnelif eval(num) > len(self.goodsinfo) or eval(num) < 1:tk.messagebox.showinfo(title='提示', message='请输入正确的序号')returnelse:delete_ls.append(self.goodsinfo[eval(num) - 1])except:tk.messagebox.showinfo(title='提示', message='请输入正确的序号')returndbc = DBConnection()for item in delete_ls:dbc.delete(item)tk.messagebox.showinfo(title='提示', message='删除成功')#主窗口def mainwindow(self):self.window.title('网购平台比价系统')self.window.geometry('1150x700')# 网站选择tk.Label(self.frm_t, text='平台选择:').place(x=30, y=30)self.c1.place(x=100, y=28)self.tm_var.set(True)self.c2.place(x=170, y=28)self.jd_var.set(True)self.c3.place(x=240, y=28)self.pdd_var.set(True)# 商品数选择tk.Label(self.frm_t, text='每个平台爬取数量:').place(x=330, y=30)self.dp_en.place(x=445, y=30)self.dp_var.set(1)# 商品选择tk.Label(self.frm_t, text='关键词:').place(x=500, y=30)self.goods_en.place(x=555, y=30)# 排序tk.Label(self.frm_b, text='排序方式:').place(x=655, y=30)self.sort_var.set(1)self.ch1.place(x=720, y=30)self.ch2.place(x=800, y=30)self.ch3.place(x=880, y=30)# 商品选择tk.Label(self.frm_b, text='请输入序号:').place(x=30, y=90)self.num_en.place(x=105, y=90)self.num_var.set('(提示:若输入多个序号请用空格隔开)')# 确认comfirm1 = tk.Button(self.frm_t, text='开始爬取', command=self.getInfo, width=20)comfirm1.place(x=980, y=30)# 开始比价comfirm2 = tk.Button(self.frm_t, text='开始比价',command=self.compare, width=20)comfirm2.place(x=500, y=90)# 加入关注列表self.comfirm3.config(command=self.addtoDB)self.comfirm3.place(x=660, y=90)# 显示关注列表comfirm4 = tk.Button(self.frm_t, text='关注列表',command=self.showDB,width=20)comfirm4.place(x=820, y=90)# 更新关注列表comfirm4 = tk.Button(self.frm_t, text='更新关注商品价格',command=self.updateDB, width=20)comfirm4.place(x=980, y=90)# 划线canvas1 = tk.Canvas(self.frm_b, bg='white', width=1095, height=3)canvas1.place(x=30, y=130)canvas2 = tk.Canvas(self.frm_b, bg='white', width=1095, height=3)canvas2.place(x=30,y=70)# 打印表格头部self.tree.column('1', width=50, anchor='w')self.tree.heading('1', text='序号')self.tree.column('2', width=100, anchor='w')self.tree.heading('2', text='ID')self.tree.column('3', width=80, anchor='w')self.tree.heading('3', text='平台')self.tree.column('4', width=300, anchor='w')self.tree.heading('4', text='标题')self.tree.column('5', width=150, anchor='w')self.tree.heading('5', text='商铺')self.tree.column('6', width=80, anchor='w')self.tree.heading('6', text='价格')self.tree.column('7', width=80, anchor='w')self.tree.heading('7', text='销量')self.tree.column('8', width=255, anchor='w')self.tree.heading('8', text='链接')self.VScroll1.place(relx=0.979, rely=0, relwidth=0.020, relheight=1)self.tree.configure(yscrollcommand=self.VScroll1.set)self.tree.place(x=30, y=150)self.window.mainloop()if __name__ =='__main__':ui = GUI()ui.mainwindow()
- python 四维数据怎么看性别_四维单子数据看男女
- python 百度云文字识别 proxy_Python基于百度AI的文字识别的示
- python 四维数据怎么看性别_四维彩超怎么看性别?四维看男孩女孩诀窍
- Python对商品属性进行二次分类并输出多层嵌套字典
- Graph Neural Network——图神经网络
- 带附属txt文件 将python文件打包成exe文件
- 聊聊“文章代写”这个传统网络项目
- 角色手游排行榜2020前十名,大型网络游戏排行榜2011前十名
- 什么游戏一天赚1000块,玩网络游戏一天可以赚到10元吗?
- macOS自带网络测速功能使用教程