appium 爬取微信的相册内容(不知什么时候能写完)
# 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 爬取微信的相册内容(不知什么时候能写完)的更多相关文章
- python爬虫24 | 搞事情了,用 Appium 爬取你的微信朋友圈。
昨天小帅b看到一些事情不顺眼 有人偷换概念 忍不住就写了一篇反讽 996 的 看不下去了,我支持996,年轻人就该996! 没想到有些人看不懂 这就算了 还来骂我 早些时候关注我的小伙伴应该知道我第一 ...
- php爬取微信文章内容
php爬取微信文章内容 在做官网升级的时遇到新的需求,需要将公司公众号文章显示在官网的文章模块下.但存在的问题是:微信文章的链接会失效,并且需要对文章部分内容做修改,同时要减少微信运营人员的工作量,避 ...
- python itchat 爬取微信好友信息
原文链接:https://mp.weixin.qq.com/s/4EXgR4GkriTnAzVxluJxmg 「itchat」一个开源的微信个人接口,今天我们就用itchat爬取微信好友信息,无图言虚 ...
- python爬取微信公众号
爬取策略 1.需要安装python selenium模块包,通过selenium中的webdriver驱动浏览器获取Cookie的方法.来达到登录的效果 pip3 install selenium c ...
- Python3 爬取微信好友基本信息,并进行数据清洗
Python3 爬取微信好友基本信息,并进行数据清洗 1,登录获取好友基础信息: 好友的获取方法为get_friends,将会返回完整的好友列表. 其中每个好友为一个字典 列表的第一项为本人的账号信息 ...
- Python爬取微信好友
前言 今天看到一篇好玩的文章,可以实现微信的内容爬取和聊天机器人的制作,所以尝试着实现一遍,本文记录了实现过程和一些探索的内容 来源: 痴海 链接: https://mp.weixin.qq.com/ ...
- 使用Python爬取微信公众号文章并保存为PDF文件(解决图片不显示的问题)
前言 第一次写博客,主要内容是爬取微信公众号的文章,将文章以PDF格式保存在本地. 爬取微信公众号文章(使用wechatsogou) 1.安装 pip install wechatsogou --up ...
- python爬取微信小程序(实战篇)
python爬取微信小程序(实战篇) 本文链接:https://blog.csdn.net/HeyShHeyou/article/details/90452656 展开 一.背景介绍 近期有需求需要抓 ...
- Python爬取微信小程序(Charles)
Python爬取微信小程序(Charles) 本文链接:https://blog.csdn.net/HeyShHeyou/article/details/90045204 一.前言 最近需要获取微信小 ...
随机推荐
- Shiro权限验证说明
1.简介 shiro是一个安全框架,是Apache的一个子项目.shiro提供了:认证.授权.加密.会话管理.与web集成.缓存等模块. 1.1.模块介绍 Authentication:用户身份识别, ...
- Python趣味入门02: 妥妥地安装配置Python(Windows版)
< 上一篇:Python趣味入门01:你真的了解Python么? 本篇内容手把手教您如何去网上下载安装Python的运行环境,本文写于2020年Python稳定的版本是3.8,Windows流行 ...
- light oj1028 - Trailing Zeroes (I)
1028 - Trailing Zeroes (I) We know what a base of a number is and what the properties are. For exa ...
- Python学习(杂)
Python学习 两个for 循环同时输出+正则文章 zip(list1,list2) zip函数同时便利两个列表 import sys import requests import re from ...
- rfc文档
你会看到很多网上关于标准的rfc文档. 如何阅读rfc 文档. https://juejin.im/post/5bf1948ff265da61553a6c97 从一个普通的RFC文档上升到Intern ...
- IntelliJ IDEA与eclipse生成JavaDoc的方法
JavaDoc是一种将注释生成HTML文档的技术. 1.使用javadoc命令生成文档 首先了解一下javadoc指令的用法 用法: javadoc [options] [packagenames] ...
- 数组翻转(非reverse)
var arr = [1,2,3,4]; var arr2 = []; while(arr.length) { var num = arr.pop(); //删除数组最后一个元素并返回被删除的元素 a ...
- Java自学-多线程 常见线程方法
Java 常见的线程方法 示例 1 : 当前线程暂停 Thread.sleep(1000); 表示当前线程暂停1000毫秒 ,其他线程不受影响 Thread.sleep(1000); 会抛出Inter ...
- springboot无法访问静态资源
无法访问static下的静态资源 1.在application.yml中添加 resources: static-locations: classpath:/META-INF/resources/,c ...
- Linux报错:rm: cannot remove 'xxx': Is a directory
rm: cannot remove 'xxx': Is a directory表示这个文件是无法remove移除的,因此我们不能仅使用rm来将这个文件夹进行删除,需要使用: rm -rf 命令则可以将 ...