国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - 如何利用python之wxpy模塊玩轉微信

如何利用python之wxpy模塊玩轉微信

2020-08-17 18:40白胡子是這個世界上最猛 Python

這篇文章主要介紹了利用python之wxpy模塊玩轉微信,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

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

?
1
bot = Bot(cache_path= True)

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

?
1
my_friends.stats_text()

效果如圖

如何利用python之wxpy模塊玩轉微信

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

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

所以衍生了下面兩個功能
功能二:群發消息

?
1
2
3
4
5
6
7
8
my_friend = bot.friends()
for i in my_friend[1:]:
 a = i.name
 friend = my_friend.search(a)[0]
 print('正在發送',friend)
 friend.send('')#你想要發送的內容
 print('ok')
 time.sleep(1)#由于發送消息太快最后加上一個延遲

功能三:消息轟炸

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

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)

效果如圖:

如何利用python之wxpy模塊玩轉微信

功能五:頭像拼接
下面展示一些 內聯代碼片

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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,這串代碼是借鑒別的大神的

如何利用python之wxpy模塊玩轉微信

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

如何利用python之wxpy模塊玩轉微信

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

如何利用python之wxpy模塊玩轉微信

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

如何利用python之wxpy模塊玩轉微信

如何利用python之wxpy模塊玩轉微信

最后附上完整代碼
下面展示一些 內聯代碼片

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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('發送成功')
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('正在發送', friend)
  friend.send(b) # 你想要發送的內容
  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 = '點擊發送信息',
        background = 'blue',
        width = 10,
        height = 4,
        command = func2)
click_button2.pack(side = 'top')
click_button3 = tkinter.Button(window,
        text ='連續發送五十',
        background = 'pink',
        width = 10,
        height = 4,
        command = func3)
click_button3.pack()
click_button4 = tkinter.Button(window,
        text ='群發信息',
        background = 'grey',
        width = 10,
        height = 4,
        command = func4)
 
click_button4.pack(side = 'bottom')
window.mainloop()

總結

到此這篇關于利用python之wxpy模塊玩轉微信的文章就介紹到這了,更多相關python wxpy模塊玩轉微信內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/Six23333/article/details/108032342

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 91成人黄色 | 中文字幕欧美日韩 | 亚洲视频精品 | 一区二区三区免费看 | 免费自拍偷拍视频 | 在线色综合| 激情小网站| 中文字幕一区二区三 | 四虎影视在线观看 | 欧美片网站免费 | 三级视频在线 | 一区二区三区影视 | 亚洲视频在线观看 | 日韩成人在线视频 | 黄色激情网站 | 九九视频在线 | 欧美日韩成人 | 国产午夜精品一区二区三区免费 | 性色av香蕉一区二区 | 国产日韩欧美在线观看 | 久久国产欧美日韩精品 | 欧美精品一二三 | 樱桃小丸子在线观看 | 中文久久| 成人av专区| 亚洲一区二区在线播放 | 日韩欧美一区在线 | 国产精品一区二区三区四区 | 国产成人在线电影 | 国产精品一区二区三区免费 | 日本在线不卡视频 | 一区二区不卡视频 | 国产一区二区在线免费观看 | 成人高清 | 91社区在线观看 | 色噜噜视频 | 亚洲精品久久久一区二区三区 | 日本久久精品视频 | 久久久久久久久99精品 | 亚洲国产精品一区二区久久 | 在线免费观看中文字幕 |