最后,通过观察屏幕中出现商品的数目得到优秀滑动距离。
- def __get_good_swipe_distance(self):
- """
- 获取每次滑动,最合适的距离
- :return:
- """
- element = Element()
- # 保存当前的UI树到本地
- element.get_current_ui_tree()
-
- # 第一个商品Item的坐标
- position_item = element.find_elment_position_by_id_and_index("com.taobao.idlefish:id/card_root",
- "1")
- # 商品的高度
- item_height = position_item[1][1] - position_item[0][1]
-
- # 通过观察,当前屏幕有3件商品
- return item_height * 3
第 4 步,筛选商品。
上面的步骤拿到优秀的滑动距离,不停的滑动页面遍历列表元素的子 Item。
需要注意的是,为了避免滑动惯性导致的误差,每一次的滑动时长最好设置为 2s 以上。
通过商品 Item 筛选出想要数目大于预设数字的商品。
- # 多少人想要
- want_element_parent = item.offspring('com.taobao.idlefish:id/search_item_flowlayout')
-
- if want_element_parent.exists():
- # 想要数/已付款数目
- want_element = want_element_parent.children()[0]
-
- want_content = want_element.get_text()
-
- # 过滤掉【已付款】等其他商品,只保留个人发布商品
- if '人想要' not in want_content:
- continue
-
- # 拿到商品想要的具体数目,代表商品热度
- want_num = get_num(want_content)
-
- if int(want_num) < self.num_assign:
- # print('不达标,过滤掉')
- pass
- else:
- # 商品想要数达标,加入统计
第 5 步,获取商品链接地址。
对于上一步满足条件的商品,点击商品 Item 进入到商品详情页面。
接着点击右上角的分享按钮,会立即弹出分享对话框。

然后点击口令控件,会提示口令复制到系统剪切板成功。
- # 点击更多
- while True:
- if self.poco('com.taobao.idlefish:id/ftShareName').exists():
- break
- print('点击更多~')
- perform_click(self.poco(text='更多'))
-
- # 点击复制淘口令
- perform_click(self.poco('com.taobao.idlefish:id/ftShareName', text='淘口令'))
-
- # 拿到口令码
- taobao_code_element = self.poco('com.taobao.idlefish:id/tvWarnDetail')
-
- taobao_code = taobao_code_element.get_text()
(编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|