From 28935dff7b923534d641280eecc51b31522494ca Mon Sep 17 00:00:00 2001 From: Zeng Jia Hua <501600635@qq.com> Date: Fri, 31 May 2024 11:20:59 +0800 Subject: [PATCH] Changes --- Python程序设计课程设计报告.doc | Bin 749037 -> 749515 bytes pythonProject1/Home.py | 20 +++++++++----------- pythonProject1/line.html | 10 +++++----- pythonProject1/login_check.py | 1 + pythonProject1/map.html | 10 +++++----- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Python程序设计课程设计报告.doc b/Python程序设计课程设计报告.doc index b63bb08e4ab03657f6f8f29b6f45644a0b8e6a89..270a62620430a67127e4766a6840a44fd7b684df 100644 GIT binary patch delta 5371 zcmZu#30xFc(tq9bz)%AQ4`6~E1E^61L`6kq&ETr>7zET14@5vDsAzzQ2Pz^OuNXu| z=OOXHh=9feL1^Q;9x?HVN-)tZQP-$3iJOgCSc%t~`2FADAp3n^|9=1O_p0kvRae)m zs_y&OgD!j*R1ob-jIlysmc-b{z!aIWxI;4zN_t079RMw`5!i#fzdwKeygE=e%9`9$ ztGhNxQ-8TF1G5)2+JfKz0MfHMD)pHOr&A%rRb)H~LiD>$0V?jdqfy zS;;MIXOh~PBip&R8frYevTLI`qumtg)&Gay1iH=~`HH)<%j@97gT3H?R>)<9@j zkLp|}MdHeDN_b(1uudCrzW@;afAz(?Tw&^U#AUI@2cu5>iLW%x*&UMgfY7p6o#7|FE@{PBM9%7c{*t=S zU!LG(d7uo_isuyXuvM_^A@TVSlpOon5YTBcf9fNR*1Cejy)Bny;8||=%g7Hzdw?SEePXtoEm;k5f+4~P zt0D6?+ok$0gjtJ#Y+y041Xv2>0Ly^f)xY-lD%3@b$QQ|DW zDJIpVw-1^r&EeV0?QLN@doR^GuB>)|e&r=pM(Zi5f>1Gun|KaH1Z3xQ<+3%$vk~&CB_0F~9I~ zZsl+1^xyn3FX!MN@=~;I2&qF{tP0sX-I>I)8sP!HQ`Weu6P)SK9+Je1UZYJB&By@{ zfycm8;159L6d6zed!Xt5ch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%iYY58pr(}A zWQGuu1;htH&X2lZ95iMOr51o#WY4>rdz4Al9)y#a>WwrYu?&& zzP@s6{<735V+Q*oCll6EOuI96DUB3MX(7u%S3IPnkIP8(*+Km*T3aq0+Fg{JF)MCV z;6NYbG{Tmbp$ux+%2#0vrBcNXKCD-CB?<$MM?6lc4ljEbtj~o(&@%-yz z=PFS!?W&|bq?eTxe+d+o@r`1qj6-S%?m*m2E0Rem-^5 zxRD`*=~7ekUK*#%Ei9m#9%L&jsVgOp$&>Ln2@q>&cK7H1z5nCoA5PXE+*h-6dolTj zY$EH$eAr#RJY)W>WHKctlDSIsJ?Ui)AInXNx*2NXF;gJc(in$lt-q0$%V&=qCRJsd z#kI@7m_0pieE5(61bk5~&uzXEif=QCS}2LV*);UpM_mk`{@QZA@iYdGA2{O#R*d1id8J}FhQwdfk{~t!b|MGK@5Hb%25&Wijr4{yd329 zA20TJWyi}nUbFEcjaOv6{NlCNUKc`mCB@4oUi|PZ<^TV8<-2ABK=Q2Np`H9PqSAJCTGmsx^{IKE&5kE-y!N9Y84>c-LEGyTj3Hm<^q$fR9Roz&9 zh{}n%hN$dV*ASHhGY?fc!CS=;m80Yts-eoPROJ9o zE*1JSmk^aLvm6S!=CqNV{SyX*p=b(T?0l%oUYasgh2IU0uqAjim*FZ$Ry|DRApJ5- a^;A|9p%NU}?U5>1?KN3Xspkw;vG6~ga*0F$ diff --git a/pythonProject1/Home.py b/pythonProject1/Home.py index 2ab9c31..982cc55 100644 --- a/pythonProject1/Home.py +++ b/pythonProject1/Home.py @@ -13,12 +13,8 @@ class Home(): self.root = tk.Tk() self.root.title("购房推荐系统") self.root.geometry("650x350+500+200") - - - self.Max_index = '' self.Current_index = 1 - # 把爬取的三条信息组成一个元组捆绑,变成一条记录 self.all_info = [] self.text='' @@ -38,7 +34,7 @@ class Home(): self.btn_line=tk.Button(self.root,text="同比房价",command=self.open_line) self.btn_line.place(relx=0.2, rely=0.8, relheight=0.10, relwidth=0.13) - + # 启动窗口事件 self.root.mainloop() def open_map(self): map() @@ -60,6 +56,7 @@ class Home(): addresses = e.xpath('//div[@class="address"]/a/@title') prices = [d.xpath('string(.)').strip() for d in e.xpath('//div[@class="nhouse_price"]')] if index=='1' and self.Max_index=='': + # 从网页获取最大页数 lasts = e.xpath('//a[@class="last"]/@href') if len(lasts)!=0: the_string = lasts[-1] @@ -69,17 +66,19 @@ class Home(): return 'False' for name, address, price in zip(names, addresses, prices): + # 将数据添加到列表中 self.all_info.append((name, price, address)) return self.all_info # 展示图表数据函数 def show_data_in_table(self,data): + # 创建一个子窗口 self.popup = tk.Toplevel(self.root) self.popup.geometry('500x500') self.popup.title("购房信息详情") - # 使用pandas DataFrame处理数据 + # 使用pandas DataFrame处理数据,二维表格数据结构 df = pd.DataFrame(data, columns=["楼盘名称", "价格", "地区"]) # 创建Treeview部件,显式指定列ID tree = ttk.Treeview(self.popup, columns=("name", "price", "area"), show="headings") @@ -100,7 +99,6 @@ class Home(): vsb = ttk.Scrollbar(self.popup, orient="vertical", command=tree.yview) tree.configure(yscrollcommand=vsb.set) vsb.pack(side='right', fill='y') - tree.pack(fill='both', expand=True) # 添加底部框架用于放置翻页按钮 @@ -149,6 +147,7 @@ class Home(): else: messagebox.showinfo(message='末尾') + # 首页点击函数 def on_button_click(self,text, index='1'): self.Max_index = '' @@ -170,12 +169,12 @@ class Home(): "石景山": "shijingshan", "密云": "miyun", }.get(text, "未知区域") - self.text=text - # 把选择的区域 传入通过fetch传入url + if self.fetch_data(simplified_text, index)!="False": + # 把选择的区域 传入通过fetch传入url data = self.fetch_data(simplified_text, index) - # 网页地址传给展示页面 + # 获取的数据传给表格 self.show_data_in_table(data) else: messagebox.showinfo(message='该地区暂无数据!') @@ -184,7 +183,6 @@ class Home(): # 获取屏幕宽度和高度 screen_width = self.popup.winfo_screenwidth() screen_height = self.popup.winfo_screenheight() - # 计算窗口的左上角应该放置的位置 left = (screen_width / 2) - (width / 2) top = (screen_height / 2) - (height / 2) diff --git a/pythonProject1/line.html b/pythonProject1/line.html index 823d33a..b56686f 100644 --- a/pythonProject1/line.html +++ b/pythonProject1/line.html @@ -7,11 +7,11 @@ -
+
diff --git a/pythonProject1/login_check.py b/pythonProject1/login_check.py index c9badfe..715045c 100644 --- a/pythonProject1/login_check.py +++ b/pythonProject1/login_check.py @@ -12,6 +12,7 @@ def check(id,psw): sql='select * from user where id = %s and password = %s' cursor.execute(sql,(id,psw)) result=cursor.fetchall() + # 返回一个多元组列表 for row in result: if id==row[0] and psw==row[1]: return True diff --git a/pythonProject1/map.html b/pythonProject1/map.html index d7d89ca..982162d 100644 --- a/pythonProject1/map.html +++ b/pythonProject1/map.html @@ -8,11 +8,11 @@ -
+