url_idshui = "approveWater_xkzgk&dataid=864cf97a36544cd0a4065812cc8f4974&isVersion=&operate=readonly"
datasshui = {"xkgk": "getxxgkContent",
"dataid": "864cf97a36544cd0a4065812cc8f4974"}
urlshui = "http://permit.mee.gov.cn/permitExt/xkgkAction!xkgk.action?xkgk=" + url_idshui
html = requests.get(urlshui).text
html = etree.HTML(html)
shuicod = html.xpath('//table[@id="fswrwinfo4"]/tr[3]/td[1]/text()')
shuiandan=html.xpath('//table[@id="fswrwinfo4"]/tr[4]/td[1]/text()')
shuicod = "".join(shuicod).replace('\n', '').replace('\r', '').replace('\t', '')
shuiandan = "".join(shuiandan).replace('\n', '').replace('\r', '').replace('\t', '')
print('COD年排放量:',shuicod)
print('氨氮年排放量:',shuiandan)
url_idshui = "approveAtmosphere_xkzgk&dataid=864cf97a36544cd0a4065812cc8f4974&isVersion=&operate=readonly"
datasshui = {"xkgk": "getxxgkContent",
"dataid": "864cf97a36544cd0a4065812cc8f4974"}
urlshui = "http://permit.mee.gov.cn/permitExt/xkgkAction!xkgk.action?xkgk=" + url_idshui
html = requests.get(urlshui).text
html = etree.HTML(html)
shuicod = html.xpath('//table[@id="spenterair"]/tr[4]/td[1]/text()')
shuiandan = html.xpath('//table[@id="spenterair"]/tr[5]/td[1]/text()')
shuicod = "".join(shuicod).replace('\n', '').replace('\r', '').replace('\t', '')
shuiandan="".join(shuiandan).replace('\n', '').replace('\r', '').replace('\t', '')
print('二氧化硫年排放量:', shuicod)
print('氮氧化物年排放量:', shuiandan)
pass
root=Tk ()
root.title("label-test")
root.geometry("800x900+300+100")
l = Label(root, text="请输入要下载的歌单URL", font=("Arial",12), width=20, height=5)
l.grid()
enter1=Entry(root)
enter1.grid(row=0,column=1)
tree = ttk.Treeview(root, show="headings")
tree.grid(row=1, columnspan=2)
tree["columns"] = ('序号','企业名称','生产经营场所地址','行业类别','所在地区','发证机关','许可证编号','办结日期','有效期限')
tree.column("序号", width=100)
tree.column("企业名称", width=100)
tree.column("生产经营场所地址", width=100)
tree.column("行业类别", width=100)
tree.column("所在地区", width=100)
tree.column("发证机关", width=100)
tree.column("许可证编号", width=100)
tree.column("办结日期", width=100)
tree.column("有效期限", width=100)
tree.heading("序号", text="序号")
tree.heading("企业名称", text="企业名称")
tree.heading("生产经营场所地址", text="生产经营场所地址")
tree.heading("行业类别", text="行业类别")
tree.heading("所在地区", text="所在地区")
tree.heading("发证机关", text="发证机关")
tree.heading("许可证编号", text="许可证编号")
tree.heading("办结日期", text="办结日期")
tree.heading("有效期限", text="有效期限")
def tree_click(event):
item_text = tree.item(tree.selection(), 'values')[2]
print(item_text)
tree.update()
tree.bind('', tree_click)
button=Button(root,text="开始下载",font=('华文行楷',10),command=download_song)
button.grid(row=5,column=0,sticky=W)
button1=Button(root,text="退出",font=('华文行楷',10),command=root.quit)
button1.grid(row=5,column=1,sticky=W)
button2=Button(root,text="保存treeview 数据")
button2.grid(row=7,column=1,sticky=W)
"""
定义滚动条控件
orient为滚动条的方向,vertical--纵向,horizontal--横向
command=self.tree.yview 将滚动条绑定到treeview控件的Y轴
"""
scroll_ty = Scrollbar(root, orient=VERTICAL, command=tree.yview)
scroll_ty.grid(row=1, column=2, sticky=N+S)
tree['yscrollcommand']=scroll_ty.set
scroll_tx = Scrollbar(root, orient=HORIZONTAL, command=tree.xview)
scroll_tx.grid(row=2, column=0, sticky=E+W)
tree['xscrollcommand']=scroll_tx.set
root.mainloop()
paiwuxukebianhao=soup.find_all('table', class_="tab0")[0].text.strip().replace('\n', '').replace('\r', '').replace(' ', '')
paiwuxkzid=paiwuxukebianhao[19:42]
paiwuxukedata=paiwuxukebianhao[45:56]
paiwuxukeyouxiaoqi=paiwuxukebianhao[69:79]
print(paiwuxkzid)
print(paiwuxukedata)
print(paiwuxukeyouxiaoqi)