from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait#可以通过xpath定位元素
from selenium.webdriver.support import expected_conditions as EC    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()

Python3+Appium爬取微信朋友圈信息相关推荐

  1. appium爬取微信朋友圈信息 真机测试

    坏境: 安卓9,荣耀10,微信7.0.11 代码: from appium import webdriver from selenium.webdriver.support.ui import Web ...

  2. Python爬虫编程思想(133):项目实战--利用Appium抓取微信朋友圈信息

    本文利用Appium实现一个抓取微信朋友圈信息的爬虫.在编写爬虫之前,先要启动Appium服务器. 编写基于Appium的爬虫,关键就是分析App每个界面相关元素的特征,也就是如何获取这些元素,然后在 ...

  3. 爬取微信朋友圈信息-可视化

    自学 pyecharts 练手,画一下基本的柱状图和地图:用 wordcloud 生成词云:用 itchat 爬取微信信息:后面的代码就是基本的朋友圈数据信息整理 导入所需包 import panda ...

  4. appium爬取微信朋友圈 安卓模拟器版

    环境: 安卓7,夜神模拟器,微信7.0.7 代码: import os import time from appium import webdriver from appium.webdriver.c ...

  5. Python爬虫爬取微信朋友圈的方法,感兴趣的朋友可以了解下

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 小雨 | 作者 python教程 | 来源 接下来,我们将实现微信朋友圈的 ...

  6. Python爬虫爬取微信朋友圈

    更多编程教程请到:菜鸟教程 https://www.piaodoo.com/ 友情链接: 高州阳光论坛https://www.hnthzk.com/ 人人影视http://www.op-kg.com/ ...

  7. Python爬虫实战项目案例——爬取微信朋友圈

    项目实战   Appium爬取微信朋友圈   自动化爬取App数据 基于移动端的自动化测试工具Appium的自动化爬取程序. 步骤 1.JDK - Download JDK,Appium要求用户必须配 ...

  8. python抓取朋友圈动态_如何利用Python网络爬虫爬取微信朋友圈动态--附代码(下)...

    原标题:如何利用Python网络爬虫爬取微信朋友圈动态--附代码(下) 前天给大家分享了如何利用Python网络爬虫爬取微信朋友圈数据的上篇(理论篇),今天给大家分享一下代码实现(实战篇),接着上篇往 ...

  9. Python爬取微信朋友圈 ! 让屏蔽你的女神无处可躲 ?

    接下来,我们将实现微信朋友圈的爬取. 如果直接用 Charles 或 mitmproxy 来监听微信朋友圈的接口数据,这是无法实现爬取的,因为数据都是被加密的.而 Appium 不同,Appium 作 ...

最新文章

  1. java 配置及Eclipse安装
  2. (C#)AJAX post方式传值
  3. JavaScript Tween算法及缓动效果
  4. win7 将文件的背景色改为绿色
  5. stdthread(3)detach
  6. 《炉石传说》架构设计赏析(3):Gameplay初探
  7. StringBuilder和Char[]在平台调用中的差异
  8. Kali Linux 网络扫描秘籍 第七章 Web 应用扫描(一)
  9. C# combobox SelectedText值为空
  10. node解决request返回内容gzip乱码问题
  11. c语言如何输出10个空格,新人提问:如何将输出时每行最后一个空格删除
  12. 泰然的粒子编辑器~~拿过来玩玩啊
  13. java nio 思维导图
  14. fragment 淡入淡出_一种模型淡入淡出时透明面重叠问题的解决方案
  15. 微信公众号配置JSAPI支付
  16. html怎样让线段显示长度,CAD想要知道线段的长度有什么技巧吗?
  17. 计算机sql查询同行并集,SQL查询交集、并集、差集
  18. 备考系统集成项目管理工程师经验
  19. Getting in Shape
  20. python求对数_python中取对数

热门文章

  1. java 三点定位_三点定位的算法
  2. Java图形化界面GUI:初接触
  3. 永磁材料知识—钕铁硼
  4. 如何找到Xcode中下载的Provisioning Profile文件
  5. 阿里云数加大数据计算服务MaxCompute文章索引(持续更新201705)
  6. PS网页设计教程II——在Photoshop中创建健康及营养或健身的网站
  7. Nginx实现一个IP访问总流量限制
  8. 5V升压12V,就是这么简单(附原理图)
  9. 英国Shadow Robot研制世界最先进机器人灵巧手,不断革新解放双手
  10. c语言绝对值题目,初中数学绝对值的练习题(整理)