这是销售人员最必不可少的Python脚本,没有之一!批量验证和添加手机号码微信好友!

115 阅读3分钟

前言

     今天去销售部找女友吃午餐,我看到她在忙,就没有打扰她!销售人员嘛,无非就是找客户然后推销自己要卖的产品!比如房地产销售就是卖房,4s店的销售就是卖车嘛!原来他们都有那种专门一键添加微信的脚本的,也叫按键精灵,但是那玩意听说要冲会员,好像还挺贵的,虽然对于一家大公司来说,这都是小钱,但是我就不一样了,你可以把要充钱的一半给我,我给你写一个免费的!

                                       

      说干就干,等我找到领导说了这件事,领导:给一半不可能的,最多这个月给你额外发五千奖金,也别给我讨价还价,不然五毛都没有,我还要找产品经理提这个需求 !果然能做领导的都是这么朴实无华!没办法,谁让我只是个小员工,还好至少有五千!当我走出领导办公室的时候、领导:对了,这个不能占用工作时间去完成啊,不然五千就没有了!

正文

  其实挺简单的,谁让领导之给我下班时间搞,那就随便写一下吧!

​​

时间来不及了,直接上源码,想让我写注释,那就先搞定我领导吧!

源码

import tkinter as tk
import pyautogui as pg
import tkinter.messagebox as msgbox
 
def setpos():
    global x,y
    try: x,y = eval(tEntry.get())
    except: pass
    pg.click(x-150,y)
    pg.typewrite('1')
    pg.moveTo(x,y,duration=0.5)
 
def alter(num):
    tList.delete(index)
    tList.insert(index,phone+','+str(num))
    user[index] = phone+','+str(num)
    with open("phones.txt","w",encoding="utf-8") as f:
        f.write('\n'.join(user))
 
def flag0():
    alter(0)
 
def flag1():
    alter(1)
 
def flag2():
    alter(2)
 
def start():
    global x,y,index,phone
    x0,y0 = pg.position()
    lines = len(user)
    index = -1
    for i in user:
        index += 1
        if len(i)==11:break
    phone = user[index]
    if len(phone)>11:
        msgbox.showinfo('提示','手机号大于11位,或全部结束!')
    else:
        try:
            t = tList.curselection()[0]
            tList.select_clear(t,t)
        except: pass
        tList.select_set(index,index)
        pg.click(x-150,y)
        pg.typewrite('\b'*50)
        pg.typewrite(phone)
        pg.moveTo(x,y,duration=0.5)
        pg.click()
        pg.moveTo(x0,y0)
 
def main():
    '''written by hannyang 2021.10.16'''
    global tEntry,tList
    global user
    
    root = tk.Tk()
    root.geometry(f'375x323+{x+55}+{y-85}')
    root.resizable(False, False)
    root.title('《企业微信好友》')
    root.wm_attributes('-topmost',True)
 
    tEntry = tk.Entry(root,width=8)
    tEntry.place(x = 275, y = 270)
    tEntry.insert(0,'995,410')
 
    bt1 = tk.Button(root,text=' 定位 ',command = setpos)
    bt1.place(x = 220, y = 265)
 
    bt2 = tk.Button(root,text=' 开始 ',command = start)
    bt2.place(x = 30, y = 265)
 
    bt3 = tk.Button(root,text=' 标0 ',command = flag0)
    bt3.place(x = 80, y = 265)
 
    bt4 = tk.Button(root,text=' 标1 ',command = flag1)
    bt4.place(x = 125, y = 265)
 
    bt5 = tk.Button(root,text=' 标2 ',command = flag2)
    bt5.place(x = 170, y = 265)
 
    user = []
    try:
        with open('phones.txt', 'r', encoding='utf-8') as fn:
            users = fn.readlines()
        for usr in users:
            if usr[-1]=='\n': usr=usr[:-1]
            user.append(usr.strip())
    except:
        user = ['当前文件夹中phones.txt文件不存在!']
        
    tScroll=tk.Scrollbar(root, orient=tk.VERTICAL)
    tScroll.place(x=330,y=25,height=220)
    
    tList=tk.Listbox(root,selectmode=tk.BROWSE,yscrollcommand=tScroll.set)
    tList.place(x=30,y=25,width=300,height=220)
 
    for i in user:
        tList.insert(tk.END,i)
        
    tScroll.config(command=tList.yview)
    tList.select_set(0,0)
    root.update()
    tmp = list(set(user))
    diff = len(user)-len(tmp)
    if diff!=0:
        msgbox.showinfo('提示',f'存在{diff}个重复手机号!可忽略')
    root.mainloop()
 
 
if __name__ == '__main__':
    
    x,y = pg.size()
    x = (x - 390)//2 + 350
    y = (y - 360)//2 + 65
    
    main()
 

                                          

 注:代码倒数两三行中,390,360是被点窗口的大小,350,65用于定位坐标。

以下是保存电话的文本文件 phones.txt 的内容,手机号码已隐去:

​​

这个可是客户隐私数据,不能给你们看了!哈哈哈  

然后看一下效果吧!

​​程序没有设置全自动的验证和添加,如果需要的话,则要把相关的按钮截图保存好.png图片,然后使用 pyautogui.locateCenterOnScreen() 等函数来定位,加上循环语句就能达成。

好了,利用中午吃饭的这半小时搞完了,我要找领导去要钱了,对了你们需要完整脚本的免费可点这里直接获取!还好你们是我粉丝,不然我少说也要收五块一个!哈哈哈

白白。下期见!