链接: https://pan.baidu.com/s/1NuAEAINVxdLEsOuyCR454w?pwd=8gxe 提取码: 8gxe 复制这段内容后打开百度网盘手机App,操作更方便哦
[Asm] 纯文本查看 复制代码import requests
import tkinter
from tkinter import messagebox
import os
import re
import pyperclip
import time
import threading
headers = {
'authority': 'mp.weixin.qq.com',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.289 Safari/537.36',
}
def getCopyTxet():
t = pyperclip.paste()
return t
def imgs(content,headers,title):
imgs=re.findall('data-src="(.*?)"',content)
num = 0
for i in imgs:
num += 1
if 'https' in i:
img_data = requests.get(i,headers=headers)
print('正在下载图片:'+i)
try:
if not os.path.exists('./'+title[:15]):
os.mkdir('./'+title[:15])
with open('./'+title[:15]+'/'+str(num)+'.jpg','wb') as f:
f.write(img_data.content)
ihtit.insert(tkinter.END, '正在下载图片:' + str(i) + '页图片成功~~' + '\n')
except:
ihtit.insert(tkinter.END, '正在下载图片出错~~' + '\n')
def copy1():
last_data = None
while True:
data = getCopyTxet()
if data != last_data:
last_data = data
sdata1 = re.search('weixin\\.qq', data)
if sdata1 != None:
print(data)
data = data.replace('&', '&')
print(data)
res = requests.get(data, headers=headers)
content = res.text
title = re.search(r'var title = \'(.*)\'', content).group(1)
print(title)
imgs(content, headers, title)
messagebox.showinfo('提示', '下载完成~~~请继续复制新文章~~')
print('下载完成~~~')
ihtit.delete('1.0','end')
time.sleep(1)
win = tkinter.Tk()
win.geometry('480x280')
win.title('公众号图片下载器')
ihLabel2=tkinter.Label(win, text='请复制公众号文章连接~~~~自动下载文章的图片~~~!',font=('宋体', '9'))
ihLabel2.place(x=20,y=15,height=19)
ihtit = tkinter.Text(win, font=('宋体', '9'))
ihtit.place(x=15, y=51, width=450, height=183)
t = threading.Thread(target=copy1)
t.start()
win.mainloop()