实战!用tkinter做一个能看得过去的界面!爬取某宝商品数据!(一键三连+打赏!!!)
Posted 布语world
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实战!用tkinter做一个能看得过去的界面!爬取某宝商品数据!(一键三连+打赏!!!)相关的知识,希望对你有一定的参考价值。
作品展示!!!
部分代码展示
'''
tkinter界面设置
'''
win = tkinter.Tk()
win.title("淘宝数据")
win.geometry("1050x500+40+30")
image2 = Image.open(r'D:\\Desktop\\C~O)OKLBO]{3H{KE$J4%12M.png')
background_image = ImageTk.PhotoImage(image2)
background_label = Label(win, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
# # 表格
tree = ttk.Treeview(win)
tree.pack()
tree.place(x=0,y=0)
# 定义列
tree["columns"] = ("itemname", "shoptitle", "sellernickname", "promotionprice","price","monthsellcount","provcity","url")
# 设置列,列还不显示
tree.column("itemname", width=100)
tree.column("shoptitle", width=100)
tree.column("sellernickname", width=100)
tree.column("promotionprice", width=50)
tree.column("price", width=50)
tree.column("monthsellcount", width=50)
tree.column("provcity", width=70)
tree.column("url", width=1000)
# 设置表头
tree.heading("itemname", text="产品名称")
tree.heading("shoptitle", text="店名")
tree.heading("sellernickname", text="卖家小名")
tree.heading("promotionprice", text="促销价格")
tree.heading("price", text="原价")
tree.heading("monthsellcount", text="月销量")
tree.heading("provcity", text="发货地")
tree.heading("url", text="网址")
e = tkinter.Variable()
path_entry = tkinter.Entry(win, textvariable=e,width=60)
path_entry.pack()
path_entry.place(x=43, y=260)
e.set("请填写csv文件的绝对路径")
label_num=tkinter.Label(win,text='page_num')
label_num.pack()
label_num.place(x=0,y=230)
label_word=tkinter.Label(win,text='key_word')
label_word.pack()
label_word.place(x=130,y=230)
label_save=tkinter.Label(win,text="保存到")
label_save.pack()
label_save.place(x=0,y=260)
num = tkinter.Entry(win, width=8)
num.pack()
num.place(x=67, y=230)
w = tkinter.Entry(win, width=20)
w.pack()
w.place(x=188, y=230)
button1=tkinter.Button(win,text="退出",command=win.quit)
button1.pack(side="bottom")
button2=tkinter.Button(win,text="一键爬取+保存",command=save_to_csv)
button2.pack()
button2.place(x=450,y=260)
win.mainloop()
私信可发源码!
以上是关于实战!用tkinter做一个能看得过去的界面!爬取某宝商品数据!(一键三连+打赏!!!)的主要内容,如果未能解决你的问题,请参考以下文章
用python tkinter 做界面时,怎么实现键盘按下回车键后,触发某个button按钮?