AS 锡安ZionTechExchange 
» 游客:  注册 | 登录 | 冻结用户(激活)?sid=PIYpT8 | 会员

RSS 订阅当前论坛  

上一主题 下一主题
       
标题: 微信自动化wxatuo程序     
 
sky999
雨局居人 Lv6



UID 181291
精华 2
积分 4
帖子 2889
金币 1255 块
阅读权限 10
注册 2020-11-28
状态 离线
微信自动化wxatuo程序

from tkinter import Entry,Button,END,Label,Text,Checkbutton,Tk,StringVar,IntVar
from tkinter import messagebox
from wxauto import WxUtils,WeChat
from tkinter.filedialog import askopenfilename
import requests
from bs4 import BeautifulSoup

root = Tk()
# 设置窗口前段显示
root.wm_attributes('-topmost',1)
#设置居中显示
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
width = 730
height = 420
#size = "%dx%d+%d+%d" % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
size = "%dx%d+%d+%d" % (width, height, 320, 230)
root.geometry(size)
# 设置窗口标题及大小
root.title('www.caffz.com -- 微信群发软件测试版1.0')
#设置接受UI界面中Label和它的位置
var = StringVar()
var.set('Tip:请先选择要发送的微信对象')
url_input=Label(root,textvariable=var,width=32,height=1,font=("微软雅黑",12))
url_input.grid(row=0,column=0,columnspan=5)
# 设置搜索框
t_url = Entry(root,width=50,font=("微软雅黑",12))
t_url.insert(0,"请把发送对象微信名称输入到names.txt, 然后点击打开文件..")
t_url.grid(row=1,column=0,columnspan=4,padx=5)
t_read = Text(root,width=50,height=10,font=("微软雅黑",12))
t_read.grid(row=3,column=0,columnspan=4,padx=5)
checkVar1 = IntVar()
checkVar2 = IntVar()
c1 = Checkbutton(root, text = "金山词霸", font=("微软雅黑",11), variable = checkVar1, onvalue = 1, offvalue = 0, height=1,width = 8)
c1.grid(row=2,column=0)
c2 = Checkbutton(root, text = "海词", font=("微软雅黑",11), variable = checkVar2, onvalue = 1, offvalue = 0, height=1,width = 8)
c2.grid(row=2,column=1)
def main():
    def get_txt(filepath): #获取发送对象
        ls=[]
        try:
            with open(filepath,"r",encoding="utf-8") as f:
                ls=[line.strip() for line in f.readlines() if line.strip()!=""]
        except Exception as exc:
            messagebox.showwarning('Warning', f'{exc}')
            t_url.delete(0,END)
        return ls
   
    def b1_prog(event=None): #打开names.txt文件,并显示在Text文本框中
        t_url.delete(0,END)
        t_read.delete("1.0", "end")
        file_path=askopenfilename(title='选择文件',filetypes=[('TXT文件','*.txt')])
        text_list=get_txt(file_path)
        t_url.insert("insert",file_path)
        for i in text_list:
            t_read.insert("insert",i+"\n")
        var.set("以下是您要发送的名单,请核对信息!")
        return file_path
    b1 = Button(root,text="导入名单",width=8,height=1,font=("微软雅黑",12),command=b1_prog)
    b1.grid(row=1,column=4)

    def jinshan():#获取金山词霸每日一句
        url = 'http://open.iciba.com/dsapi/'
        #url = 'http://www.caffz.com:10180/ip11.php'
        res = requests.get(url)
        content = res.json()['content'] + res.json()['note']
        return content
    def haici():#获取海词每日一句
        url2=r"http://dict.cn"
        resp = requests.get(url2)
        soup = BeautifulSoup(resp.text,"html.parser")
        htm=soup.find("div",class_="daily_sentence")
        sen=htm.text.strip().split("\t\t\t")[2] #split("\n\t")[2].strip()
        return sen
    def get_sentence():# 获取每日一句信息
        msg="每日一句:"
        
        if checkVar1.get() ==1 and checkVar2.get() ==1:
            t_read.delete("1.0", "end")
            msg=msg+jinshan()+"\n"+haici()
        elif checkVar1.get() ==1 and checkVar2.get() ==0:
            t_read.delete("1.0", "end")
            msg=msg+jinshan()
        elif checkVar1.get() ==0 and checkVar2.get() ==1:
            t_read.delete("1.0", "end")
            msg=msg+haici()
        else:
            messagebox.showwarning("错误信息","请选中金山词霸或者海词")
        return msg
    def b2_prog():# 显示每日一句信息,校对并准备发送。
        msgs=get_sentence()
        for m in msgs:
            t_read.insert('insert',m)
        var.set("以下是您要发送内容,输入内容即可!")
    b2 = Button(root,text="句子测试",width=8,height=1,font=("微软雅黑",12),command=b2_prog)
    b2.grid(row=2,column=4)
    def wechat(who,msg):#查询发送对象
        wx = WeChat()
        # 获取会话列表
        wx.GetSessionList()
        for w in who:
            wx.ChatWith(w)  # 打开`文件传输助手`聊天窗口
            wx.SendMsg(msg)  # 向`文件传输助手`发送消息:你好~
    def send_txt(): # 发送信息
        filepath=t_url.get()
        if not filepath.endswith(".txt"):
            messagebox.showwarning("错误信息","请先打开文件!")
        else:
            who=get_txt(filepath)
            msgs=get_sentence()
            t_read.delete("1.0", "end")
            wechat(who,msgs)
            messagebox.showwarning("成功信息","您的信息已经发送成功!")
    b3 = Button(root,text="开始发送",width=8,height=1,font=("微软雅黑",12),command=send_txt)
    b3.grid(row=3,column=4,pady=20)
    root.mainloop()
main()
2022-11-17 16:49#1
查看资料  发短消息  顶部
 
com
超级版主
Rank: 12Rank: 12


UID 1
精华 1
积分 1
帖子 119
金币 297 块
阅读权限 200
注册 2022-2-7
状态 离线
python程序。
2023-1-14 23:09#2
查看资料  Blog  发短消息  顶部
 
com
超级版主
Rank: 12Rank: 12


UID 1
精华 1
积分 1
帖子 119
金币 297 块
阅读权限 200
注册 2022-2-7
状态 离线
微信群发软件-测试版1.0, 免费下载使用。 采用python+wxauto自动化工具库开发。欢迎测试、使用。(Read all
http://cloud.caffz.com:12345/mud ... =255616&fid=467
来源: CAFFZ Knowledge Library [Fantasy World] - 拉尔斯帝国 Lars Empire《曼多力亚都会Metropolitan Mandoria - 生产力系统设计与研发*》(City)
Author:xander,等级:  Lv3
2023-1-15 11:57#3
查看资料  Blog  发短消息  顶部
       


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题  


 


所有时间为 GMT+8, 现在时间是 2024-3-29 14:14 清除 Cookies - 联系我们 - ZAKE萨尔克岛 - AbyssalSwamp深渊之沼