-
大小: 2KB文件類型: .py金幣: 1下載: 0 次發布日期: 2021-05-11
- 語言: Python
- 標簽: request??BeautifulSou??re??tkinter??
資源簡介
Python做的垃圾分類查詢,基于網站 "https://lajifenleiapp.com/"做的一個軟件,能快速分類垃圾
代碼片段和文件信息
import?requests
from?bs4?import?BeautifulSoup
from?urllib.request?import?quote
import?re
import?tkinter?as?tk
window?=?tk.Tk()
window.title(‘垃圾分類查詢‘)
window.geometry(‘500x300‘)??#?這里的乘是小x
def?check_Action():
????s_garbage?=?var_garbage.get()????
????#?轉碼
????sGoods?=?quote(s_garbageencoding=‘utf-8‘)
????try:
????????r?=?requests.get(‘https://lajifenleiapp.com/sk/‘?+?sGoods)
????????#?獲取數據
????????bs_ele=?BeautifulSoup(r.text‘html.parser‘)
????????bs_all_row?=?bs_ele.find_all(‘div‘?class_?=?‘row‘)
????????bs_row?=?bs_all_row[2]
????????bs_span?=?bs_row.find_all(‘span‘)
????????#?魚骨
????????#print(bs_span[0].text)
????????#?屬于
????????match_obj?=?re.findall(r‘[\u4e00-\u9fa5]+‘bs_span[1].text)
????????#print(match_obj[0])
????????#?濕垃圾(廚余垃圾)
????????#print(bs_span[2].text)????
????????s_what.set(bs_span[0].text)
????????s_belog.set(match_obj[0])
????????s_target.set(bs_span[2].text)????????
????except?Exception:
????????s_
- 上一篇:用tkinter實線圖片拖動
- 下一篇:redis-2.10.6.tar.gz
評論
共有 條評論