airtest爬取app内容

1.以知乎为例爬取数据:

airtest爬取app内容

# -*- encoding=utf8 -*-
from airtest.core.api import *
from airtest.core.android.android import Android
auto_setup(__file__)
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
poco=AndroidUiautomationPoco(force_restart=False)
connect_device(Android:///)
poco(name=com.zhihu.android:id/input).click()
sleep(3)
poco(name=com.zhihu.android:id/input).set_text(追风筝的人)
sleep(4)

title_obj_list = poco(name=com.zhihu.android:id/magi_title)#行的元素(内容行)
title_list = [title.get_text() for title in title_obj_list]#迭代title_obj_list元素的个数(也教遍历)
#print(title_list)
discuss_obj_list = poco(name=com.zhihu.android:id/magi_count)#行对应的讨论数
discuss_list = [discuss.get_text() for discuss in discuss_obj_list]#遍历discuss_obj_list
#遍历格式化
for title, discuss in zip(title_list, discuss_list):
    print(title, discuss)
exit()

 

airtest爬取app内容

上一篇:android实现以activity方式的dialog对话框


下一篇:NetCore控制台程序-使用HostService和HttpClient实现简单的定时爬虫