欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何利用python之wxpy模塊玩轉(zhuǎn)微信

 更新時(shí)間:2020年08月17日 11:38:52   作者:白胡子是這個(gè)世界上最猛的男人  
這篇文章主要介紹了利用python之wxpy模塊玩轉(zhuǎn)微信,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

wxpy也是一個(gè)python的模塊,利用它我們可以做很多有意思的事情
首先利用一句代碼我們就可以利用python登錄網(wǎng)頁版微信

bot = Bot(cache_path= True)

這條語句會(huì)產(chǎn)生一個(gè)二維碼,我們掃描了這個(gè)二維碼之后就可以登錄我們的微信了
功能一:獲得微信好友信息
利用一行語句獲得你微信好友的個(gè)數(shù)、男女比例、TOP10省份及TOP10城市

my_friends.stats_text()

效果如圖

利用下面兩行代碼我們可以給微信好友發(fā)送信息

friends = my_friends.search('你想要發(fā)送的人名')[0]
friends.send('你想要發(fā)送的信息')

所以衍生了下面兩個(gè)功能
功能二:群發(fā)消息

my_friend = bot.friends()
for i in my_friend[1:]:
 a = i.name
 friend = my_friend.search(a)[0]
 print('正在發(fā)送',friend)
 friend.send('')#你想要發(fā)送的內(nèi)容
 print('ok')
 time.sleep(1)#由于發(fā)送消息太快最后加上一個(gè)延遲

功能三:消息轟炸

friends = my_friends.search('你想要發(fā)送的人名')[0]
for i in range(50):
 friends.send('你想要發(fā)送的信息')

我這里是發(fā)了50遍,記得加上time.sleep(),要是發(fā)送太快會(huì)被禁止發(fā)信息的
功能四:獲得好友頭像
利用friend.get_avatar函數(shù)

def CREATE_PICPATHT():
 path = os.getcwd() +"\\pic\\"
 if not os.path.exists(path):
  os.mkdir(path)
  return path
def IMAGE_SAVE(path):
 my_friends = bot.friends()
 num = 0
 for friend in my_friends:
  print(friend.name)
  friend.get_avatar(path + '\\' + str(num) + ".jpg")
  num = num + 1
path = CREATE_PICPATHT()
IMAGE_SAVE(path)

效果如圖:

功能五:頭像拼接
下面展示一些 內(nèi)聯(lián)代碼片。

def PJ_IMAGE(path):
 length = len(os.listdir(path))
 image_size = 2560
 each_size = math.ceil(2560 / math.floor(math.sqrt(length)))
 x_lines = math.ceil(math.sqrt(length))
 y_lines = math.ceil(math.sqrt(length))
 image = Image.new('RGB', (each_size * x_lines, each_size * y_lines))
 x = 0
 y = 0
 for (root, dirs, files) in os.walk(path):
  for pic_name in files:
   try:
    with Image.open(path + pic_name) as img:
     img = img.resize((each_size, each_size))
     image.paste(img, (x * each_size, y * each_size))
     x += 1
     if x == x_lines:
      x = 0
      y += 1
   except IOError:
    print("頭像讀取失敗")
  img = image.save(os.getcwd() +"/wechat.png")
  print('已完成')

path就是上面獲得頭像的path,這串代碼是借鑒別的大神的

最后我把代碼整合在了一起并加上了按鈕和界面,如下圖

輸入的用戶名可以是備注也可以是原名,然后群發(fā)的消息也是放在第二行點(diǎn)擊一下就好了,好友信息會(huì)以txt的文件存放,好友圖片會(huì)放在文件夾里,雖然亞子有點(diǎn)丑

最后我也打包成了exe文件,可以直接執(zhí)行


最后附上完整代碼
下面展示一些 內(nèi)聯(lián)代碼片。

from wxpy import *
import os
import tkinter as tk
import tkinter
import math
from PIL import Image
import time
window = tkinter.Tk()
window.title('微信')
window.geometry("800x480")
bot = Bot(cache_path= True)
l1 = tk.Label(window, text="第一行輸入用戶名第二行輸入信息",
    font=("黑體", 10))
l1.pack()
ask_text = tk.Entry(background = 'orange')
ask_text.pack()
ask_text1 = tk.Entry(background = 'pink')
ask_text1.pack()
def onclick():
 a = ask_text.get()
 my_friends = bot.friends()
 friends = my_friends.search(a)
 return friends[0]
def onclick1():
 a = ask_text1.get()
 return a
def CREATE_PICPATHT():
 path = os.getcwd() +"\\pic\\"
 if not os.path.exists(path):
  os.mkdir(path)
  return path
def IMAGE_SAVE(path):
 my_friends = bot.friends()
 num = 0
 for friend in my_friends:
  print(friend.name)
  friend.get_avatar(path + '\\' + str(num) + ".jpg")
  num = num + 1
def CREATE_TXTPATH():
 a = os.getcwd()
 filename = a + '\用戶信息' + '.txt'
 return filename
def GET_FriendSTXT(filenmame):
 my_friend = bot.friends()
 with open(filenmame,'w') as f:
  f.write(my_friend.stats_text())
 print('ok')
def SEARCH_FRIENDS(name):
 my_friends = bot.friends()
 friends = my_friends.search(name)
 return friends[0]
def SEND_MESSAGES(friends,message):
 friends.send(message)
def func():
 path = CREATE_TXTPATH()
 GET_FriendSTXT(path)
def func1():
 path = CREATE_PICPATHT()
 IMAGE_SAVE(path)
 PJ_IMAGE(path)
def func2():
 a = onclick()
 b = onclick1()
 a.send(b)
 print('發(fā)送成功')
def func3():
 for i in range(50):
  time.sleep(1)
  func2()
def PJ_IMAGE(path):
 length = len(os.listdir(path))
 image_size = 2560
 each_size = math.ceil(2560 / math.floor(math.sqrt(length)))
 x_lines = math.ceil(math.sqrt(length))
 y_lines = math.ceil(math.sqrt(length))
 image = Image.new('RGB', (each_size * x_lines, each_size * y_lines))
 x = 0
 y = 0
 for (root, dirs, files) in os.walk(path):
  for pic_name in files:
   try:
    with Image.open(path + pic_name) as img:
     img = img.resize((each_size, each_size))
     image.paste(img, (x * each_size, y * each_size))
     x += 1
     if x == x_lines:
      x = 0
      y += 1
   except IOError:
    print("頭像讀取失敗")
  img = image.save(os.getcwd() +"/wechat.png")
  print('已完成')

def func4():
 my_friend = bot.friends()
 b = onclick1()
 for i in my_friend[1:]:
  a = i.name
  friend = my_friend.search(a)[0]
  print('正在發(fā)送', friend)
  friend.send(b) # 你想要發(fā)送的內(nèi)容
  print('ok')
  time.sleep(1)
window.bind('<Return>', onclick)
click_button = tkinter.Button(window,
        text = '獲取好友信息',
        background = 'purple',
        width = 10,
        height = 4,
        command = func)

click_button.pack(side = 'left')
click_button1 = tkinter.Button(window,
        text = '獲取好友圖片',
        background = 'green',
        width = 10,
        height = 4,
        command = func1)
click_button1.pack(side = 'right')
click_button2 = tkinter.Button(window,
        text = '點(diǎn)擊發(fā)送信息',
        background = 'blue',
        width = 10,
        height = 4,
        command = func2)
click_button2.pack(side = 'top')
click_button3 = tkinter.Button(window,
        text ='連續(xù)發(fā)送五十',
        background = 'pink',
        width = 10,
        height = 4,
        command = func3)
click_button3.pack()
click_button4 = tkinter.Button(window,
        text ='群發(fā)信息',
        background = 'grey',
        width = 10,
        height = 4,
        command = func4)

click_button4.pack(side = 'bottom')
window.mainloop()

總結(jié)

到此這篇關(guān)于利用python之wxpy模塊玩轉(zhuǎn)微信的文章就介紹到這了,更多相關(guān)python wxpy模塊玩轉(zhuǎn)微信內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Pytorch之nn.Upsample()和nn.ConvTranspose2d()用法詳解

    Pytorch之nn.Upsample()和nn.ConvTranspose2d()用法詳解

    nn.Upsample和nn.ConvTranspose2d是PyTorch中用于上采樣的兩種主要方法,nn.Upsample通過不同的插值方法(如nearest、bilinear)執(zhí)行上采樣,沒有可學(xué)習(xí)的參數(shù),適合快速簡單的尺寸增加,而nn.ConvTranspose2d通過可學(xué)習(xí)的轉(zhuǎn)置卷積核進(jìn)行上采樣
    2024-10-10
  • 詳解pandas apply 并行處理的幾種方法

    詳解pandas apply 并行處理的幾種方法

    這篇文章主要介紹了詳解pandas apply 并行處理的幾種方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • 詳解Python self 參數(shù)

    詳解Python self 參數(shù)

    這篇文章主要介紹了Python self 參數(shù)詳解,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-08-08
  • python flask sqlalchemy連接數(shù)據(jù)庫流程介紹

    python flask sqlalchemy連接數(shù)據(jù)庫流程介紹

    這篇文章主要介紹了python flask sqlalchemy連接數(shù)據(jù)庫流程,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-09-09
  • 快速下載VScode并配置Python運(yùn)行環(huán)境(圖文教程)

    快速下載VScode并配置Python運(yùn)行環(huán)境(圖文教程)

    本文主要介紹了快速下載VScode并配置Python運(yùn)行環(huán)境,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • git進(jìn)行版本控制心得詳談

    git進(jìn)行版本控制心得詳談

    這篇文章主要介紹了git進(jìn)行版本控制的心得和經(jīng)驗(yàn),給并大家總結(jié)了作者的技巧,需要的朋友們參考一下吧。
    2017-12-12
  • MacBook m1芯片采用miniforge安裝python3.9的方法示例

    MacBook m1芯片采用miniforge安裝python3.9的方法示例

    這篇文章主要介紹了MacBook m1芯片采用miniforge安裝python3.9的方法示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • Python+pandas數(shù)據(jù)分析實(shí)踐總結(jié)

    Python+pandas數(shù)據(jù)分析實(shí)踐總結(jié)

    這篇文章主要介紹了Python+pandas數(shù)據(jù)分析實(shí)踐總結(jié)的相關(guān)資料,需要的朋友可以參考下
    2023-07-07
  • python編寫腳本之pyautogui的安裝和使用教程

    python編寫腳本之pyautogui的安裝和使用教程

    pyautogui一個(gè)神奇的圖像自動(dòng)化庫,學(xué)會(huì)之后無所不能,下面這篇文章主要給大家介紹了關(guān)于python編寫腳本之pyautogui的安裝和使用的相關(guān)資料,需要的朋友可以參考下
    2021-12-12
  • Python中turtle.write方法使用說明

    Python中turtle.write方法使用說明

    turtle模塊以面向?qū)ο蠛兔嫦蜻^程的方式提供turtle圖形基元,由于它使用Tkinter作為基礎(chǔ)圖形,因此需要安裝有Tk支持的Python版本,下面這篇文章主要給大家介紹了關(guān)于Python中turtle.write方法使用說明的相關(guān)資料,需要的朋友可以參考下
    2022-02-02

最新評(píng)論