python tkinter實(shí)現(xiàn)下載進(jìn)度條及抖音視頻去水印原理
利用python爬取網(wǎng)站數(shù)據(jù)進(jìn)行下載時(shí),顯示下載進(jìn)度
# 設(shè)置下載進(jìn)度條tk.Label(window, text=’下載進(jìn)度:’).place(x=40, y=80)canvas = tk.Canvas(window, width=600, height=16, bg='white')canvas.place(x=20, y=90)# 下載按鈕函數(shù)def usr_download(): response = session.get(url_str, headers=headers2, cookies=cookies_xxx, verify=False, stream=True) # stream=True表示請(qǐng)求成功后并不會(huì)立即開始下載,而是在調(diào)用iter_content方法之后才會(huì)開始下載 chunk_size = 40960 # 設(shè)置每次下載的塊大小 content_size = int(m4a.headers[’content-length’]) # 從返回的response的headers中獲取文件大小 # 填充進(jìn)度條 fill_line = canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill='green') raise_data = 600 / (content_size/chunk_size) # 增量大小,600為進(jìn)度條的長(zhǎng)度 # 將下載的數(shù)據(jù)寫入文件 with open(title + ’.m4a’, ’wb’) as f: n = 0 for data in response.iter_content(chunk_size=chunk_size): # 在循環(huán)讀取文件時(shí),刷新進(jìn)度條f.write(data) n = n + raise_data canvas.coords(fill_line, (0, 0, n, 60)) window.update() # 清空進(jìn)度條def clean_progressbar(): # 清空進(jìn)度條 fill_line = canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill='white') x = 500 # 未知變量,可更改 n = 600 / x # 465是矩形填充滿的次數(shù) for t in range(x): n = n + 600 / x # 以矩形的長(zhǎng)度作為變量值更新 canvas.coords(fill_line, (0, 0, n, 60)) window.update() # 下載按鈕btn_download = tk.Button(window, text=’開始下載’, command=usr_download)btn_download.place(x=600, y=28)
效果圖:
https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=6832178122364816644
3.把 playwm 改成 play以上就是python tkinter實(shí)現(xiàn)下載進(jìn)度條及抖音視頻去水印原理的詳細(xì)內(nèi)容,更多關(guān)于python 下載進(jìn)度條及抖音視頻去水印的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. ajax請(qǐng)求添加自定義header參數(shù)代碼2. ASP基礎(chǔ)知識(shí)VBScript基本元素講解3. Gitlab CI-CD自動(dòng)化部署SpringBoot項(xiàng)目的方法步驟4. Python requests庫參數(shù)提交的注意事項(xiàng)總結(jié)5. Kotlin + Flow 實(shí)現(xiàn)Android 應(yīng)用初始化任務(wù)啟動(dòng)庫6. 利用CSS3新特性創(chuàng)建透明邊框三角7. vue-electron中修改表格內(nèi)容并修改樣式8. ASP中解決“對(duì)象關(guān)閉時(shí),不允許操作。”的詭異問題……9. python操作mysql、excel、pdf的示例10. 詳談ajax返回?cái)?shù)據(jù)成功 卻進(jìn)入error的方法
