Giter Site home page Giter Site logo

valord577 / auto_add_wechat_friends_py Goto Github PK

View Code? Open in Web Editor NEW
122.0 6.0 44.0 12.04 MB

微信添加好友 批量发送添加请求 脚本 python

License: Apache License 2.0

Python 39.30% JavaScript 0.39% Shell 0.02% Makefile 0.01% C++ 0.95% C 0.03% HTML 59.30%
add-friend wechat-bot adb python3

auto_add_wechat_friends_py's Introduction

auto_add_wechat_friends_py

微信自动发送添加好友请求脚本 python

使用指南

  • python version > 3.3
  • android手机打开usb调试
  • android手机允许模拟点击(一部分手机有 如小米6x)
  • 运行结果会以txt文件格式导出 (目录自动创建) ./result/${yyyyMMdd}/*.txt

python run.py

  • 提示使用 python run.py -h 或 python run.py --help

python run.py -h

  • 显示详细使用帮助 -h 或 --help
  • 优先级最高 且与其他参数冲突

python run.py -d

  • 使用adb的默认端口 和 默认设备(usb有且仅有一个android设备)
  • 优先级第二 且与其他参数冲突

python run.py -s xxx

  • 绑定adb操作的设备号 多设备适用

python run.py -p xxx

  • 绑定adb运行的端口号 adb端口被占用适用(鲁大师 360手机助手等)

python run.py -p xxx -s xxx

  • 绑定adb操作的设备号和运行的端口号

配置环境

  • ./config/config.json 配置:
    - mode => 添加联系人模式 file | loop
    - loop => 循环首尾 包含首 不包含尾
    - file => 文件相对路径 手机号码一行一个 自动处理换行符\n
    - account => 自动切换账号 微信登录 微信预留账号
    - dump => 累计查找结果达到指定个数 会从内存写入到文件
    - sleep => 休眠时间 单位分钟
    - sleep-flag => 查找失败 会切换账号 切换账号到指定次数 会休眠
  • 创建python独立虚拟环境:
    1. # pip3 install --upgrade pip virtualenv setuptools
    2. # virtualenv --no-site-packages venv
        # virtualenv --no-site-packages -p /usr/bin/python3.7 venv
    3. # ./venv/bin/python run.py -h

技术堆栈

  • 采用adb命令对android手机 模拟点击
  • adb shell uiautomator dump /sdcard/dump.xml 截图当前屏幕节点
  • 采用xml.etree.cElementTree对该xml文件进行分析并计算点击的坐标

思路来源

开源协议

Copyright 2018 valord577

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

auto_add_wechat_friends_py's People

Contributors

valord577 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

auto_add_wechat_friends_py's Issues

bug 一堆,能在md文档写个使用流程吗

▶ python3 run.py -d
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 5.2 MB/s (23633 bytes in 0.004s)
Traceback (most recent call last):
File "run.py", line 90, in
run(sys.argv[1:])
File "run.py", line 43, in run
fun.main()
File "/Users/lmy/dev/android/wechat/auto_add_wechat_friends_py/main.py", line 193, in main
self.init()
File "/Users/lmy/dev/android/wechat/auto_add_wechat_friends_py/main.py", line 58, in init
self._adb.click_by_text_after_refresh('通讯录')
File "/Users/lmy/dev/android/wechat/auto_add_wechat_friends_py/adb.py", line 132, in click_by_text_after_refresh
self.click_by_text(text, index)
File "/Users/lmy/dev/android/wechat/auto_add_wechat_friends_py/adb.py", line 124, in click_by_text
self.click(0)
File "/Users/lmy/dev/android/wechat/auto_add_wechat_friends_py/adb.py", line 119, in click
self.cal_coordinate(cal_index)
File "/Users/lmy/dev/android/wechat/auto_add_wechat_friends_py/adb.py", line 104, in cal_coordinate
_bounds = self._nodes[_index]['bounds']
IndexError: list index out of range

测试了一下微信7.0.4版本,可以用!

由于微信界面调整的原因,所以作者的流程需要微调,比如‘添加到联系人’需要改为‘添加到通讯录’等等。

def init(self):
self._adb.click_by_content_after_refresh('更多功能按钮')
self._adb.click_by_text_after_refresh('添加朋友')
#self._adb.click_by_text_after_refresh('外部联系人')
#self._adb.click_by_text_after_refresh('添加')
#self._adb.click_by_text_after_refresh('微信号/手机号')

上面是init的修改,微信要先停留在主界面
然后执行 python run.py -d 即可正常运行

微信6.7.3 play版无法正常使用

您好,我在我的一加3上无法正常使用(可以模拟点击),修改代码后部分功能可以正常使用
devices info:
ONEPLUS A3000
Android 8.0.0
WeChat: 6.7.3 Google Play

主要是界面显示的文字不一样造成的bug,下图是修改前后main.py 文件的对比,
第70行的搜索:那里您使用了中文的冒号,微信实际的是英文冒号
image
image
image
同时main.py 中的第196行在python3.7上报错(修改了普通文字后)
image

报错信息如下:

Traceback (most recent call last):
  File "run.py", line 90, in <module>
    run(sys.argv[1:])
  File "run.py", line 43, in run
    fun.main()
  File "****\auto_add_wechat_friends_py-master\main.py", line 196, in main
    with self._file.open(self._file) as f:
AttributeError: 'str' object has no attribute 'open'

我使用时将该行改成了直接打开文件,就可以使用(绝对路径)
代码如下: with open(r'D:\dadada\data\name.txt',encoding='UTF-8') as f:

多设备的问题

我启动时设置了端口号,设备号,但是在adb.py中的cal_coordinate这个函数调用有问题,方便加个合作吗?我的微信号是:18210564586

咋回事啊?大佬

Active code page: 65001
ERROR: null root node returned by UiTestAutomationBridge.
Active code page: 65001
/sdcard/dump.xml: 1 file pulled. 7.1 MB/s (29588 bytes in 0.004s)
Traceback (most recent call last):
File "run.py", line 90, in
run(sys.argv[1:])
File "run.py", line 43, in run
fun.main()
File "G:\auto_add_wechat_friends_py-master\main.py", line 193, in main
self.init()
File "G:\auto_add_wechat_friends_py-master\main.py", line 58, in init
self._adb.click_by_text_after_refresh('通讯录')
File "G:\auto_add_wechat_friends_py-master\adb.py", line 132, in click_by_text_after_refresh
self.click_by_text(text, index)
File "G:\auto_add_wechat_friends_py-master\adb.py", line 124, in click_by_text
self.click(0)
File "G:\auto_add_wechat_friends_py-master\adb.py", line 119, in click
self.cal_coordinate(cal_index)
File "G:\auto_add_wechat_friends_py-master\adb.py", line 104, in cal_coordinate
_bounds = self._nodes[_index]['bounds']
IndexError: list index out of range

微信7.0运行到一半,遇到一个问题(不知道还在不在维护)

UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 8.4 MB/s (48276 bytes in 0.005s)
[{'index': '1', 'text': '通讯录', 'resource-id': 'com.tencent.mm:id/d7b', 'class': 'android.widget.TextView', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'false', 'enabled': 'true', 'focusable': 'false', 'focused': 'false', 'scrollable': 'false', 'long-clickable': 'false', 'password': 'false', 'selected': 'false', 'bounds': '[234,1311][306,1344]'}]
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 10.1 MB/s (40386 bytes in 0.004s)
[{'index': '0', 'text': '新的朋友', 'resource-id': '', 'class': 'android.widget.TextView', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'false', 'enabled': 'true', 'focusable': 'false', 'focused': 'false', 'scrollable': 'false', 'long-clickable': 'false', 'password': 'false', 'selected': 'false', 'bounds': '[144,176][312,222]'}]
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 6.0 MB/s (10009 bytes in 0.002s)
[{'index': '0', 'text': '添加朋友', 'resource-id': 'com.tencent.mm:id/jw', 'class': 'android.widget.TextView', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'true', 'enabled': 'true', 'focusable': 'true', 'focused': 'false', 'scrollable': 'false', 'long-clickable': 'true', 'password': 'false', 'selected': 'false', 'bounds': '[520,48][720,144]'}]
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 9.4 MB/s (31894 bytes in 0.003s)
[{'index': '1', 'text': '微信号/QQ号/手机号', 'resource-id': 'com.tencent.mm:id/d85', 'class': 'android.widget.TextView', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'false', 'enabled': 'true', 'focusable': 'false', 'focused': 'false', 'scrollable': 'false', 'long-clickable': 'false', 'password': 'false', 'selected': 'false', 'bounds': '[32,189][688,251]'}]
===== 开始查找 ===== 13029620003 =====
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 2.7 MB/s (6852 bytes in 0.002s)
[{'index': '0', 'text': '微信号/QQ号/手机号', 'resource-id': 'com.tencent.mm:id/kh', 'class': 'android.widget.EditText', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'true', 'enabled': 'true', 'focusable': 'true', 'focused': 'true', 'scrollable': 'false', 'long-clickable': 'true', 'password': 'false', 'selected': 'false', 'bounds': '[80,73][704,119]'}]
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 5.2 MB/s (8896 bytes in 0.002s)
[{'index': '1', 'text': '搜索:13029620003', 'resource-id': 'com.tencent.mm:id/mf', 'class': 'android.widget.TextView', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'false', 'enabled': 'true', 'focusable': 'false', 'focused': 'false', 'scrollable': 'false', 'long-clickable': 'false', 'password': 'false', 'selected': 'false', 'bounds': '[160,185][720,231]'}]
==> 点击搜索 ==>
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 6.2 MB/s (21502 bytes in 0.003s)
UI hierchary dumped to: /sdcard/dump.xml
/sdcard/dump.xml: 1 file pulled. 7.1 MB/s (21502 bytes in 0.003s)
[{'NAF': 'true', 'index': '1', 'text': '', 'resource-id': 'com.tencent.mm:id/b3t', 'class': 'android.widget.ImageView', 'package': 'com.tencent.mm', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'true', 'enabled': 'true', 'focusable': 'true', 'focused': 'false', 'scrollable': 'false', 'long-clickable': 'false', 'password': 'false', 'selected': 'false', 'bounds': '[0,224][720,352]'}]
Traceback (most recent call last):
File "run.py", line 90, in
run(sys.argv[1:])
File "run.py", line 43, in run
fun.main()
File "/home/kerwin/桌面/auto_add_wechat/main.py", line 203, in main
self.add_friends(str(line))
File "/home/kerwin/桌面/auto_add_wechat/main.py", line 190, in add_friends
self._adb.click(1)
File "/home/kerwin/桌面/auto_add_wechat/adb.py", line 121, in click
self.cal_coordinate(cal_index)
File "/home/kerwin/桌面/auto_add_wechat/adb.py", line 106, in cal_coordinate
_bounds = self._nodes[_index]['bounds']
IndexError: list index out of range

运行到添加到通讯录页面

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.