# 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. 关于在osgearth 中 出现 arial.ttf : file not handled 的问题

    这是由于配置osg时 freetype 插件没有配置到位. 我个人的解决方法 打开CMAKE,点击advance,不勾选OSG_TEXT_USE_FONTCONFIG. 同时将freetype路径设置 ...

  2. SPH流体模拟及液面重构问题

    关于流体特效模拟算法的简单描述,前提部分. 目前动画领域内的流体模拟主要是拉格朗日法无网格法和欧拉网格法,两种方法更有利弊. 我研究的主要是拉格朗日法中的SPH模型,即光滑粒子流体动力学模型. 粒子方 ...

  3. Mac-Mysql忘记root密码

    cd /usr/local/mysql/bin 切换到root权限 ,需要输入密码: sudo su 输入之后会看见如下信息: sh-3.2# 使用如下命令以安全模式运行mysql ./mysqld_ ...

  4. 幸存者偏差Survivorship Bias

    "最不符合逻辑的地方,一定埋藏着最深刻的逻辑."——余秋雨<行者无疆> 为什么要说幸存者偏差? 因为2018年全国II卷的描述即为典型的“幸存者偏差”,且这一例子被引入 ...

  5. java jni 调用c语言函数

    今日在hibernate源代码中遇到了native关键词,甚是陌生,就查了点资料,对native是什么东西有了那么一点了解,并做一小记. native关键字说明其修饰的方法是一个原生态方法,方法对应的 ...

  6. Java并发之Exchanger类

    应用场景 如果两个线程在运行过程中需要交换彼此的信息,可以使用Exchanger这个类. Exchanger为线程交换信息提供了非常方便的途径,它可以作为两个线程交换对象的同步点,只有当每个线程都在进 ...

  7. NPOI word文档表格在新的文档中多次使用

    最近有一个项目,涉及到文档操作,有一个固定的模版,模版中有文字和表格,表格会在新的文档中使用n多次 //获取模版中的表格FileStream stream = new FileStream(strPa ...

  8. coat 彩色的cat

    # 和cat类似,但每一行一种颜色,方便查看 curl -o coat https://raw.githubusercontent.com/oldratlee/useful-scripts/maste ...

  9. 如何用Java8 Stream API找到心仪的女朋友

    传统的的Java 集合操作是有些啰嗦的,当我们需要对结合元素进行过滤,排序等操作的时候,通常需要写好几行代码以及定义临时变量. 而Java8 Stream API 可以极大简化这一操作,代码行数少,且 ...

  10. 共同战“疫”,CODING 帮助研发团队高效协同

    新冠疫情下,家里蹲的日子继续延长.部分企业虽然受困于不能回公司办公,但都陆续开启了远程协作办公,远程协作领域被推上了风口.但「远程协同」看不见摸不着工作伙伴,个人的自律能力也无法保证,难免出现沟通响应 ...