美文网首页大数据 爬虫Python AI SqlPython小哥哥
用 Python 薅羊毛,每天早餐有着落了!

用 Python 薅羊毛,每天早餐有着落了!

作者: 14e61d025165 | 来源:发表于2019-06-18 14:55 被阅读2次

    1

    目 标 场 景

    以今日头条极速版为首,包含趣头条、东方头条、全名小视频在内的 App 都有看新闻、视频送金币的活动,当金币达到一定量后,就可以提现到微信、支付包。

    如果单纯靠人工去点击看新闻和视频,会浪费很多时间。本文的目标是利用 Python 驱动手机去看新闻和视频,每天帮我们薅一个早餐钱。

    下面以「东方头条」客户端为例展开说明。

    2

    准 备 工 作

    元素的定位需要借助 Airtes,需要在 PC 端进行安装,具体可以参考上一篇。另外这里以 Android 系统手机为例,所以提前配置好了 adb 环境。

    另外,需要在虚拟环境内安装「pocoui」库。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">pip3 install pocoui Python学习交流群:1004391443
    </pre>

    3

    分 析 思 路

    首先我们需要利用 adb 命令打开东方头条 App。

    使用 Android Studio 的 Analyze Apk 工具,可以获取应用包名和初始 Activity 分别是:

    com.songheng.eastnews

    com.oa.eastfirst.activity.WelcomeActivity

    <tt-image data-tteditor-tag="tteditorTag" contenteditable="false" class="syl1560840837592 ql-align-center" data-render-status="finished" data-syl-blot="image" style="box-sizing: border-box; cursor: text; text-align: left; color: rgb(34, 34, 34); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: block;"> image

    <input class="pgc-img-caption-ipt" placeholder="图片描述(最多50字)" value="" style="box-sizing: border-box; outline: 0px; color: rgb(102, 102, 102); position: absolute; left: 187.5px; transform: translateX(-50%); padding: 6px 7px; max-width: 100%; width: 375px; text-align: center; cursor: text; font-size: 12px; line-height: 1.5; background-color: rgb(255, 255, 255); background-image: none; border: 0px solid rgb(217, 217, 217); border-radius: 4px; transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></tt-image>

    然后使用「adb shell am start」命令去打开东方头条的客户端。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"># 应用包名
    package_name = 'com.songheng.eastnews'

    初始Activity

    activity = 'com.oa.eastfirst.activity.WelcomeActivity'
    def start_my_app(package_name, activity_name):
    """
    打开应用
    adb shell am start -n com.tencent.mm/.ui.LauncherUI
    :param package_name:
    :return:
    """
    os.popen('adb shell am start -n %s/%s' % (package_name, activity_name))
    start_my_app(package_name, activity)
    </pre>

    由于第一次打开应用,会有一个显示广告的界面,我们需要通过 Airtest 获取到「跳过广告」元素,执行点击操作,让应用快速进入到主页面。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">def _pre_and_skip_ads(self):
    """
    预加载和跳过广告
    :return:
    """
    # 1.广告页面元素的出现
    # 两种样式:跳过、跳过广告
    try:
    poco('com.songheng.eastnews:id/aoy').wait_for_appearance(10)
    except Exception as e:
    print('等待广告元素异常')
    print(e)
    ads_element = poco(name='com.songheng.eastnews:id/aoy', textMatches='^跳过广告.
    /pre>)
    ads_element1 = poco(name='android.widget.TextView', text='跳过')
    # 跳过广告(0s)
    if ads_element.exists():
    print('跳过广告1!!!')
    ads_element.click()
    if ads_element1.exists():
    print('跳过广告2!!!')
    ads_element1.click()
    # 2.等到到达主页面
    poco('com.songheng.eastnews:id/g
    ').wait_for_appearance(120)
    </pre>

    到达主页面之后,我们发现主要有 3 种方式获取金币,分别是「阅读文章」、「播放视频」、「播放小视频」,另外一种获取金币的方式就是归纳于其他方式中。

    首先,我们使用 Airtest 来分析新闻 Tab 的列表。

    新闻列表可以通过获取 name 为「com.songheng.eastnews:id/g_」 的元素,再取其所有子元素就能获取到第一页的新闻列表。

    <tt-image data-tteditor-tag="tteditorTag" contenteditable="false" class="syl1560840837620 ql-align-center" data-render-status="finished" data-syl-blot="image" style="box-sizing: border-box; cursor: text; text-align: left; color: rgb(34, 34, 34); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: block;"> image

    <input class="pgc-img-caption-ipt" placeholder="图片描述(最多50字)" value="" style="box-sizing: border-box; outline: 0px; color: rgb(102, 102, 102); position: absolute; left: 187.5px; transform: translateX(-50%); padding: 6px 7px; max-width: 100%; width: 375px; text-align: center; cursor: text; font-size: 12px; line-height: 1.5; background-color: rgb(255, 255, 255); background-image: none; border: 0px solid rgb(217, 217, 217); border-radius: 4px; transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></tt-image>

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">lv_elements = poco('com.songheng.eastnews:id/g_').children()
    if not lv_elements.exists():
    print('新闻列表不存在')
    return

    遍历每一条新闻

    for news_element in lv_elements:
    # 新闻标题
    news_title = news_element.offspring('com.songheng.eastnews:id/pb')
    #作者
    author_element = news_element.offspring('com.songheng.eastnews:id/a4f')
    </pre>

    需要注意的是,上面获取的新闻列表中有很多广告和点击下载的内容,需要过滤掉。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"># 4.过滤广告

    到这里标识此条新闻:是一条有效的新闻【包含广告】

    注意:部分广告【包含点击标题就自动下载,左下角显示广告字眼等】要过滤掉

    场景一:

    if news_element.attr('name') == 'android.widget.FrameLayout':
    print('广告!这是一个FrameLayout广告,标题是:%s' % news_title.get_text())
    continue

    常见二:点击标题直接下载其他应用

    ads_tips_element = news_element.offspring(name='com.songheng.eastnews:id/a4f', text='广告通')
    if ads_tips_element.exists():
    print('广告!这是一个【广点通】广告,标题是:%s' % news_title.get_text())
    continue

    常见三:有效角标识是广告的图标【奇虎广告】

    ads_tips_element2 = news_element.offspring('com.songheng.eastnews:id/q5')
    if ads_tips_element2.exists():
    print('广告!广告标题是:%s' % news_title.get_text())
    continue
    </pre>

    只有判断是一条正常的新闻,才点击新闻的标题元素进入新闻详情页面,如果右下角的「时间条元素」存在才代表阅读此篇新闻能获取到金币。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">red_coin_element = poco('com.songheng.eastnews:id/aq8')
    if not red_coin_element.exists():
    print('当前新闻没有红包,返回!')
    self.__back_keyevent()
    continue
    </pre>

    <tt-image data-tteditor-tag="tteditorTag" contenteditable="false" class="syl1560840837683 ql-align-center" data-render-status="finished" data-syl-blot="image" style="box-sizing: border-box; cursor: text; text-align: left; color: rgb(34, 34, 34); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: block;"> image

    <input class="pgc-img-caption-ipt" placeholder="图片描述(最多50字)" value="" style="box-sizing: border-box; outline: 0px; color: rgb(102, 102, 102); position: absolute; left: 187.5px; transform: translateX(-50%); padding: 6px 7px; max-width: 100%; width: 375px; text-align: center; cursor: text; font-size: 12px; line-height: 1.5; background-color: rgb(255, 255, 255); background-image: none; border: 0px solid rgb(217, 217, 217); border-radius: 4px; transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></tt-image>

    为了更真实的模拟人为看新闻这一操作,随机地模拟向上或向下滑动屏幕。

    这里设置每篇文章阅读时间为 30 秒,阅读完成之后,执行返回操作,直到回到主界面,这样就完成了查看一篇新闻获取金币的流程。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">oldtime = datetime.datetime.now()
    while True:
    self.__swipe(True if random.randint(0, 1) == 0 else False)
    newtime = datetime.datetime.now()
    interval_time = (newtime - oldtime).seconds
    if interval_time >= 30:
    print('阅读30秒新闻完成')
    break
    self.__read_key_news()
    </pre>

    接着可以从下往上滑动页面,获取到新的页面的新闻列表,循环的进行阅读。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> while True:
    self.watch_news_recommend()
    print('查看一页完成,继续查看下一页的新闻。')
    # 滑动下一页的新闻
    poco.swipe([0.5, 0.8], [0.5, 0.3], duration=1)
    </pre>

    另外,注意应用的标题栏隔一段时间可以领取金币,定义一个方法去领取。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">def get_top_title_coin(self):
    """
    顶部金币领取
    仅仅在新闻首页的时候才可以领取
    :return:
    """
    get_coin_element = poco(name='com.songheng.eastnews:id/arq', text="领取")
    if get_coin_element.exists():
    print('顶部有金币可以领取!')
    get_coin_element.click()
    print('领完金币后可以关闭对话框!')
    # 关掉对话框
    self.__back_keyevent()
    else:
    print('顶部没有金币或者不在首页')
    </pre>

    然后可以点击视频 Tab 去切换到视频页面。和看新闻一样,这里同样是获取视频列表元素去遍历查看视频。

    <tt-image data-tteditor-tag="tteditorTag" contenteditable="false" class="syl1560840837731 ql-align-center" data-render-status="finished" data-syl-blot="image" style="box-sizing: border-box; cursor: text; text-align: left; color: rgb(34, 34, 34); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: block;"> image

    <input class="pgc-img-caption-ipt" placeholder="图片描述(最多50字)" value="" style="box-sizing: border-box; outline: 0px; color: rgb(102, 102, 102); position: absolute; left: 187.5px; transform: translateX(-50%); padding: 6px 7px; max-width: 100%; width: 375px; text-align: center; cursor: text; font-size: 12px; line-height: 1.5; background-color: rgb(255, 255, 255); background-image: none; border: 0px solid rgb(217, 217, 217); border-radius: 4px; transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></tt-image>

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> def __video(self):
    """
    查看视频
    :return:
    """
    poco('com.songheng.eastnews:id/ko').click()
    while True:
    # 视频列表
    poco('com.songheng.eastnews:id/a0z').wait_for_appearance()
    sleep(2)
    self.__read_key_news()
    video_elements = poco('com.songheng.eastnews:id/a0z').children()
    print('video items是否存在:')
    print(video_elements.exists())
    # 遍历视频
    # 注意:视频播放完全可以提前返回
    for video_element in video_elements:
    # 1.标题元素
    video_title_element = video_element.offspring('com.songheng.eastnews:id/a3q')
    # 播放按钮
    video_play_element = video_element.offspring('com.songheng.eastnews:id/nj')
    # 2.必须保证【视频标题】和【播放按钮】都可见
    if not video_title_element.exists() or not video_play_element.exists():
    continue
    # 3.标题
    video_title = video_element.offspring('com.songheng.eastnews:id/a3q').get_text()
    print('当前视频的标题是:%s,播放当前视频' % video_title)
    # 点击播放视频
    video_play_element.focus("center").click()
    # 4.播放视频
    self.play_video()
    print('播放下一个视频')
    self.__back_keyevent()
    # 滑动到下一页的视频
    poco.swipe([0.5, 0.8], [0.5, 0.3], duration=0.2)
    </pre>

    观看小视频获取金币的操作最为简单。首先切换到小视频 Tab,获取到第一个视频的元素,执行点击操作,开始播放小视频。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">poco('com.songheng.eastnews:id/kr').click()

    加载出列表元素,点击第一项进入

    poco('com.songheng.eastnews:id/a0p').child('com.songheng.eastnews:id/g_').wait_for_appearance(60)
    poco('com.songheng.eastnews:id/a0p').child('com.songheng.eastnews:id/g_').children()[0].click()
    </pre>

    <tt-image data-tteditor-tag="tteditorTag" contenteditable="false" class="syl1560840837809 ql-align-center" data-render-status="finished" data-syl-blot="image" style="box-sizing: border-box; cursor: text; text-align: left; color: rgb(34, 34, 34); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: block;"> image

    <input class="pgc-img-caption-ipt" placeholder="图片描述(最多50字)" value="" style="box-sizing: border-box; outline: 0px; color: rgb(102, 102, 102); position: absolute; left: 187.5px; transform: translateX(-50%); padding: 6px 7px; max-width: 100%; width: 375px; text-align: center; cursor: text; font-size: 12px; line-height: 1.5; background-color: rgb(255, 255, 255); background-image: none; border: 0px solid rgb(217, 217, 217); border-radius: 4px; transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></tt-image>

    最后只需要等待视频播放 30 秒之后,使用 swipe 函数向左滑动屏幕切换到下一个视频,就可以实现反复播放获取金币的操作。

    <pre spellcheck="false" style="box-sizing: border-box; margin: 5px 0px; padding: 5px 10px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; font-size: 16px; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; background-color: rgb(240, 240, 240); border-radius: 3px; white-space: pre-wrap; color: rgb(34, 34, 34); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">while True:
    sleep(30)
    # 向左滑动
    poco.swipe([0.9, 0.5], [0.1, 0.5], duration=0.2)
    </pre>

    <tt-image data-tteditor-tag="tteditorTag" contenteditable="false" class="syl1560840837836 ql-align-center" data-render-status="finished" data-syl-blot="image" style="box-sizing: border-box; cursor: text; text-align: left; color: rgb(34, 34, 34); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: block;"> image

    <input class="pgc-img-caption-ipt" placeholder="图片描述(最多50字)" value="" style="box-sizing: border-box; outline: 0px; color: rgb(102, 102, 102); position: absolute; left: 187.5px; transform: translateX(-50%); padding: 6px 7px; max-width: 100%; width: 375px; text-align: center; cursor: text; font-size: 12px; line-height: 1.5; background-color: rgb(255, 255, 255); background-image: none; border: 0px solid rgb(217, 217, 217); border-radius: 4px; transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></tt-image>

    4

    结 果 结 论

    执行程序,手机会自动打开东方头条客户端,执行阅读新闻、看视频和小视频的一系列操作。

    最后只需要将阅读新闻、播放视频和小视频的时间分配好,一个客户端获取金币达到上限后,就关闭应用,然后切换到其他 App 客户端,继续阅读新闻和视频,就可以实现薅多个平台的羊毛。

    如果你觉得文章还不错,请大家点赞分享下。你的肯定是我最大的鼓励和支持。

    相关文章

      网友评论

        本文标题:用 Python 薅羊毛,每天早餐有着落了!

        本文链接:https://www.haomeiwen.com/subject/dyefqctx.html