Compare commits

..

2 Commits

Author SHA1 Message Date
Zeng Jia Hua 4eb8e8a826 5month31day
6 months ago
Zeng Jia Hua 28935dff7b Changes
6 months ago

@ -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)

@ -7,11 +7,11 @@
</head>
<body >
<div id="230081edc72b4d1bb7f50f04c025a37b" class="chart-container" style="width:1000px; height:500px; "></div>
<div id="9fd5d1f853624e32a8c5489accd89458" class="chart-container" style="width:1000px; height:500px; "></div>
<script>
var chart_230081edc72b4d1bb7f50f04c025a37b = echarts.init(
document.getElementById('230081edc72b4d1bb7f50f04c025a37b'), 'white', {renderer: 'canvas'});
var option_230081edc72b4d1bb7f50f04c025a37b = {
var chart_9fd5d1f853624e32a8c5489accd89458 = echarts.init(
document.getElementById('9fd5d1f853624e32a8c5489accd89458'), 'white', {renderer: 'canvas'});
var option_9fd5d1f853624e32a8c5489accd89458 = {
"animation": true,
"animationThreshold": 2000,
"animationDuration": 1000,
@ -418,7 +418,7 @@
}
}
};
chart_230081edc72b4d1bb7f50f04c025a37b.setOption(option_230081edc72b4d1bb7f50f04c025a37b);
chart_9fd5d1f853624e32a8c5489accd89458.setOption(option_9fd5d1f853624e32a8c5489accd89458);
</script>
</body>
</html>

@ -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

@ -8,11 +8,11 @@
</head>
<body >
<div id="c7ffa23106124fae8285c749fb373293" class="chart-container" style="width:900px; height:500px; "></div>
<div id="d0fb9d34f04c48478903edec1d99e7e4" class="chart-container" style="width:900px; height:500px; "></div>
<script>
var chart_c7ffa23106124fae8285c749fb373293 = echarts.init(
document.getElementById('c7ffa23106124fae8285c749fb373293'), 'white', {renderer: 'canvas'});
var option_c7ffa23106124fae8285c749fb373293 = {
var chart_d0fb9d34f04c48478903edec1d99e7e4 = echarts.init(
document.getElementById('d0fb9d34f04c48478903edec1d99e7e4'), 'white', {renderer: 'canvas'});
var option_d0fb9d34f04c48478903edec1d99e7e4 = {
"animation": true,
"animationThreshold": 2000,
"animationDuration": 1000,
@ -213,7 +213,7 @@
"borderWidth": 0
}
};
chart_c7ffa23106124fae8285c749fb373293.setOption(option_c7ffa23106124fae8285c749fb373293);
chart_d0fb9d34f04c48478903edec1d99e7e4.setOption(option_d0fb9d34f04c48478903edec1d99e7e4);
</script>
</body>
</html>

Loading…
Cancel
Save