溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人

發(fā)布時(shí)間:2021-10-18 14:24:55 來源:億速云 閱讀:215 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要講解了“怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人”吧!

目錄
  • 需求

  • 源碼

  • 運(yùn)行

需求

批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信賬號的聯(lián)系人

怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人

源碼

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('提示','手機(jī)號大于11位,或全部結(jié)束!')
    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('《企業(yè)微信好友》')
    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=' 標(biāo)0 ',command = flag0)
    bt3.place(x = 80, y = 265)
 
    bt4 = tk.Button(root,text=' 標(biāo)1 ',command = flag1)
    bt4.place(x = 125, y = 265)
 
    bt5 = tk.Button(root,text=' 標(biāo)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 = ['當(dāng)前文件夾中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}個(gè)重復(fù)手機(jī)號!可忽略')
    root.mainloop()
 
 
if __name__ == '__main__':
    
    x,y = pg.size()
    x = (x - 390)//2 + 350
    y = (y - 360)//2 + 65
    
    main()

注:代碼倒數(shù)兩三行中,390,360是被點(diǎn)窗口的大小,350,65用于定位坐標(biāo)。

以下是保存電話的文本文件 phones.txt 的內(nèi)容,手機(jī)號碼已隱去:

怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人

運(yùn)行

怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人

程序沒有設(shè)置全自動的驗(yàn)證和添加,如果需要的話,則要把相關(guān)的按鈕截圖保存好.jpg圖片,然后使用 pyautogui.locateCenterOnScreen() 等函數(shù)來定位,加上循環(huán)語句就能達(dá)成。

感謝各位的閱讀,以上就是“怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對怎么用Python批量驗(yàn)證和添加手機(jī)號碼為企業(yè)微信聯(lián)系人這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI