appium爬取微信朋友圈信息 真机测试
坏境: 安卓9,荣耀10,微信7.0.11
代码:
from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC # 可以通过xpath定位元素
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.by import By
import time
import re# 连接手机
PLATFROM = 'Android'
DEVICE_NAME = 'COL_AL10'
APP_PACKGE = 'com.tencent.mm'
APP_ACTIVITY = '.ui.LauncherUI'
DRIVER_SERVER = 'http://localhost:4723/wd/hub'
TIMEOUT = 300class Moments():def __init__(self):# 驱动配置self.desired_caps = {'platformName': PLATFROM,'deviceName': DEVICE_NAME,'appPackage': APP_PACKGE,'appActivity': APP_ACTIVITY,# 下面这句话不用重置微信了,直接登录手机上的微信"noReset": 'true'}self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)self.wait = WebDriverWait(self.driver, TIMEOUT)def enter(self):time.sleep(3)el2 = self.driver.find_element_by_xpath("//android.widget.FrameLayout[@content-desc=\"当前所在页面,与的聊天\"]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.RelativeLayout[3]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.ImageView")el2.click()time.sleep(3)el3 = self.driver.find_element_by_xpath("//android.widget.FrameLayout[@content-desc=\"当前所在页面,与的聊天\"]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/com.tencent.mm.ui.mogic.WxViewPager/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout")el3.click()self.get_onepage_elementlist()def get_onepage_elementlist(self):FLICK_START_X = 300FLICK_START_Y = 300FLICK_DISTANCE = 810i=0contents = []while True:# 带图朋友圈配文和视频朋友圈配文content = self.driver.find_element_by_id("com.tencent.mm:id/f4m").get_attribute("text")print(content)i = i+1contents.append(content)time.sleep(2)# 上滑self.driver.swipe(FLICK_START_X, FLICK_START_Y + FLICK_DISTANCE, FLICK_START_X, FLICK_START_Y)if i>= 107:break# 避免重复获取到的朋友圈信息,通过元祖进行避免for i in range(0, len(contents)-1):if contents[i] == contents[i+1]:passelse:f = open('content.txt','a',encoding='utf-8')f.write('%s' % contents[i])f.write('\n\n' + '-------------------------------------------------------------------------------------------------------------------------------------------------' + '\n\n')print('程序已结束')if __name__ == "__main__":start = Moments()start.enter()
成果:
appium爬取微信朋友圈信息 真机测试相关推荐
- Python3+Appium爬取微信朋友圈信息
from appium import webdriver from selenium.webdriver.support.ui import WebDriverWait#可以通过xpath定位元素 f ...
- Python爬虫编程思想(133):项目实战--利用Appium抓取微信朋友圈信息
本文利用Appium实现一个抓取微信朋友圈信息的爬虫.在编写爬虫之前,先要启动Appium服务器. 编写基于Appium的爬虫,关键就是分析App每个界面相关元素的特征,也就是如何获取这些元素,然后在 ...
- 爬取微信朋友圈信息-可视化
自学 pyecharts 练手,画一下基本的柱状图和地图:用 wordcloud 生成词云:用 itchat 爬取微信信息:后面的代码就是基本的朋友圈数据信息整理 导入所需包 import panda ...
- appium爬取微信朋友圈 安卓模拟器版
环境: 安卓7,夜神模拟器,微信7.0.7 代码: import os import time from appium import webdriver from appium.webdriver.c ...
- Python爬虫爬取微信朋友圈的方法,感兴趣的朋友可以了解下
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 小雨 | 作者 python教程 | 来源 接下来,我们将实现微信朋友圈的 ...
- Python爬虫爬取微信朋友圈
更多编程教程请到:菜鸟教程 https://www.piaodoo.com/ 友情链接: 高州阳光论坛https://www.hnthzk.com/ 人人影视http://www.op-kg.com/ ...
- Python爬虫实战项目案例——爬取微信朋友圈
项目实战 Appium爬取微信朋友圈 自动化爬取App数据 基于移动端的自动化测试工具Appium的自动化爬取程序. 步骤 1.JDK - Download JDK,Appium要求用户必须配 ...
- python抓取朋友圈动态_如何利用Python网络爬虫爬取微信朋友圈动态--附代码(下)...
原标题:如何利用Python网络爬虫爬取微信朋友圈动态--附代码(下) 前天给大家分享了如何利用Python网络爬虫爬取微信朋友圈数据的上篇(理论篇),今天给大家分享一下代码实现(实战篇),接着上篇往 ...
- Python爬取微信朋友圈 ! 让屏蔽你的女神无处可躲 ?
接下来,我们将实现微信朋友圈的爬取. 如果直接用 Charles 或 mitmproxy 来监听微信朋友圈的接口数据,这是无法实现爬取的,因为数据都是被加密的.而 Appium 不同,Appium 作 ...
最新文章
- cii框架PHP,CII. POSIX Functions - PHP 5 中文文档
- Ubuntu 16.04安装unrar解压RAR文件
- BZOJ4161 常系数齐次线性递推
- 通过数据库动态视图'v$',查看数据库信息
- Javascript图像处理之将彩色图转换成灰度图
- poj1273Drainage Ditches
- 《Redis入门指南》第2版 读书笔记
- 为什么11·11物流一年比一年快?奥秘就在这里!
- 怎么一秒钟给微信头像戴上圣诞帽,我教你啊
- RocksDB 6.0.1 发布,Facebook 推出的存储系统
- 订阅个人Blog最新评论的方法
- oracle分区实战,Oracle分区实战分享
- app逆向 安卓开发环境搭建
- 手机图片怎么免费转换成PDF格式?教程来了
- 程序员100套简历模板,全网最全
- depends工具查看exe和dll依赖关系
- sumo学习——sumo的路网介绍
- 实验3ospf路由聚合
- This scheduler instance (XXXXX) is still active but was recovered by another
- 第三章 编译器基础知识之ELF文件格式简介