# crowl wechat through appium

from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time server = "http://localhost:4723/wd/hub" # http setting
# appium desired_cap settings
desired_capabilities = {
"platformName":"Android", # Android platform
"platformVersion":"8.1.0", # Android version
"deviceName":"bc0896140804", # the phone name
"appPackage":"com.tencent.mm", # the appPackage name
"appActivity":".ui.LauncherUI ", # appActivity name ,the first time seems that i copy others code .
"autoGrantPermissions":True, # permissioin
"unicodeKeyboard":True, # can input chinese
"restKeyboard":True } driver = webdriver.Remote(server, desired_capabilities) # connect phone
wait = WebDriverWait(driver,50) # wait 50ms
login = wait.until(EC.presence_of_element_located((By.ID, "com.tencent.mm:id/drp"))) # wait until we find specific ID
login.click() # lick the button
inputPhoneNumber = wait.until(EC.presence_of_element_located((By.ID,"com.tencent.mm:id/ji"))) # wait until we find spocific ID
inputPhoneNumber.send_keys("") # input number to the input field
nextButton = wait.until(EC.presence_of_element_located((By.ID, "com.tencent.mm:id/ast"))) # wait until we find specific button
nextButton.click() # click the button
inputPassword = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@resource-id="com.tencent.mm:id/czc"]/android.widget.EditText'))) # wait until we find specific button
inputPassword.send_keys("emotion1") # input content to the input field
nextButton1 = wait.until(EC.presence_of_element_located((By.ID, "com.tencent.mm:id/ast"))) # wait until we find specific button
nextButton1.click() # click the button
time.sleep(20) # sleep 30 seconds
chooseYes = wait.until(EC.presence_of_element_located((By.ID,"com.tencent.mm:id/au_"))) # find the Yes button
chooseYes.click() # click the button
time.sleep(20) # wait 30 minutes chooseMe = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@resource-id="com.tencent.mm:id/bh"]//android.widget.RelativeLayout[4]'))) # find the fourth element which has the same class and has no id, so first find father if then, find the special class element by XPATH. notice the quotation mark
# 上面一行为关键一行,have two questions
# 第一点://*[@resource-id="com.tencent.mm:id/bh"]//android.widget.RelativeLayout,这一行后面为什么不能加上[@class=],按理说android.widget.RelativeLayout并不是标签。
#那么如果改成//*[@resource-id="com.tencent.mm:id/bh"]//[@class=android.widget.RelativeLayout]可不可以?
#第二点:为什么不能用//*[@resource-id="com.tencent.mm:id/bh"][4]这种方式去索引,难道不一样吗?而自己的实验证明不成功。 chooseMe.click() # click the button # choosePhotoAlbum = wait.until(EC.presence_of_element_located((By.ID,"com.tencent.mm:id/kl"))) # find the photo album button
# above line is the fist ID(钱包这个选项),because id can be duplicated. this button is not the right button
# the button can run succussfully, it proved that we can click the button even thouthg the view show that the button is not clickable.
# it prove that monitor.bat is not completely right choosePhotoAlbum = wait.until(EC.presence_of_all_elements_located((By.XPATH,'//*[@resource-id="com.tencent.mm:id/kl"]')))[2]
# oh my god 居然这种方式可行,you should notice the code wait.until(EC.presence_of_all_elements_located((By.XPATH,'//*[@resource-id="com.tencent.mm:id/kl"]')))[2]
# use this code we can select element through quantation, also you should know that using By.ID[3] is not correct ,i do not know why.
# and using EC.presence_of_all_elements_located((By.XPATH,'//*[@resource-id="com.tencent.mm:id/kl"]'))[2]) is not correct eithor, because the position of the quantation is not correct choosePhotoAlbum.click() # click the button
print(11111111111111111111) # 只是验证程序的进程
time.sleep(10) # sometimes the phone is very slow , wait the phone refresh.
downloadInformation = wait.until(EC.presence_of_all_elements_located((By.ID,"com.tencent.mm:id/mi"))) # find elements which contains text
# and the number of tags which contains text is two
print(2222222222222222) # 只是验证程序的进程
resultList = [] # create a empty list
for i in downloadInformation:
word = i.get_attribute("text") # obtain the text in every tag
resultList.append(word) # add the text to the list print(resultList) # com.tencent.mm:id/jv
# com.tencent.mm:id/mi 有表情
# com.tencent.mm:id/jv 只有表情
# com.tencent.mm:id/jv 基本上就只有这两个

第一个坑:要安装上python,安装上selenium,安装上appium, 以上三个都是基于python的。其次安装appium客户端,安装

(明天接着写)

appium 爬取微信的相册内容(不知什么时候能写完)的更多相关文章

  1. python爬虫24 | 搞事情了,用 Appium 爬取你的微信朋友圈。

    昨天小帅b看到一些事情不顺眼 有人偷换概念 忍不住就写了一篇反讽 996 的 看不下去了,我支持996,年轻人就该996! 没想到有些人看不懂 这就算了 还来骂我 早些时候关注我的小伙伴应该知道我第一 ...

  2. php爬取微信文章内容

    php爬取微信文章内容 在做官网升级的时遇到新的需求,需要将公司公众号文章显示在官网的文章模块下.但存在的问题是:微信文章的链接会失效,并且需要对文章部分内容做修改,同时要减少微信运营人员的工作量,避 ...

  3. python itchat 爬取微信好友信息

    原文链接:https://mp.weixin.qq.com/s/4EXgR4GkriTnAzVxluJxmg 「itchat」一个开源的微信个人接口,今天我们就用itchat爬取微信好友信息,无图言虚 ...

  4. python爬取微信公众号

    爬取策略 1.需要安装python selenium模块包,通过selenium中的webdriver驱动浏览器获取Cookie的方法.来达到登录的效果 pip3 install selenium c ...

  5. Python3 爬取微信好友基本信息,并进行数据清洗

    Python3 爬取微信好友基本信息,并进行数据清洗 1,登录获取好友基础信息: 好友的获取方法为get_friends,将会返回完整的好友列表. 其中每个好友为一个字典 列表的第一项为本人的账号信息 ...

  6. Python爬取微信好友

    前言 今天看到一篇好玩的文章,可以实现微信的内容爬取和聊天机器人的制作,所以尝试着实现一遍,本文记录了实现过程和一些探索的内容 来源: 痴海 链接: https://mp.weixin.qq.com/ ...

  7. 使用Python爬取微信公众号文章并保存为PDF文件(解决图片不显示的问题)

    前言 第一次写博客,主要内容是爬取微信公众号的文章,将文章以PDF格式保存在本地. 爬取微信公众号文章(使用wechatsogou) 1.安装 pip install wechatsogou --up ...

  8. python爬取微信小程序(实战篇)

    python爬取微信小程序(实战篇) 本文链接:https://blog.csdn.net/HeyShHeyou/article/details/90452656 展开 一.背景介绍 近期有需求需要抓 ...

  9. Python爬取微信小程序(Charles)

    Python爬取微信小程序(Charles) 本文链接:https://blog.csdn.net/HeyShHeyou/article/details/90045204 一.前言 最近需要获取微信小 ...

随机推荐

  1. Go语言实现:【剑指offer】复杂链表的复制

    该题目来源于牛客网<剑指offer>专题. 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head.( ...

  2. JumpServer部署与管理

    一.JumpServer 堡垒机概述 JumpServer由Python/Django进行开发.使用GNU GPL v2.0开源协议.也是全球首款完全开源的堡垒机.同时配备了业界领先的Web Term ...

  3. MSSqlServer访问远程数据库

    --第一部分(要点)--永久访问方式(需对访问远程数据库进行经常性操作)时设置链接数据库Exec sp_addlinkedserver 'MyLinkServer','','SQLOLEDB','远程 ...

  4. Cacti 升级

    现在用的 cacti 1.0.3   决定升级一下cacti到最新版本 1.1.1   官方升级指导文件 Upgrading Cacti Backup the old Cacti database. ...

  5. 用Docker部署自己的JupyterHub

    [话在前头] 用 Docker 部署 JupyterLab 感觉是部署 JupyterLab 最方便的方式了,官方提供了很多可选的镜像,也可以自己从 jupyter/base-notebook 中继续 ...

  6. css中伪类和伪元素

    伪类和伪元素时对那些我们不能通过class.id等选择元素的补充 伪类的操作对象是文档树中已有的元素(可以给已有元素加了一个类替代),而伪元素则创建了一个文档数外的元素(可以添加一个新元素替代) CS ...

  7. 小白学 Python 数据分析(8):Pandas (七)数据预处理

    人生苦短,我用 Python 前文传送门: 小白学 Python 数据分析(1):数据分析基础 小白学 Python 数据分析(2):Pandas (一)概述 小白学 Python 数据分析(3):P ...

  8. vue.extend 拓展

    https://www.w3cplus.com/vue/vue-extend.html https://jspang.com/post/vue2-2.html https://blog.csdn.ne ...

  9. Win环境下安装vue及运行vue开发的前端项目

    vue安装及配置 首先下载node.js要求版本在8.9以上        官网:https://nodejs.org/zh-cn/ 下载完可检查在windows任务命令行里输入node -v 使用淘 ...

  10. Vue.js 起步

    通过实例来看下 Vue 构造器中需要哪些内容 测试时这段代码我直接写在index.html中 <!DOCTYPE html> <html> <head> <m ...