如何实现python自动打开B站视频点赞并评论3?(随机选择不同评论)电脑分辨率1920*1080

import pyautogui
import time
import webbrowser
import random
import pyperclip
import os

rp = 1
for rp in range(150):
    # 浏览器运行目录
    chromePath = r"C:\Program Files\Google\Chrome\Application\chrome.exe"

    # 注册浏览器
    webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chromePath))

    # 获取浏览器并打开指定地址
    webbrowser.get('chrome').open('https://www.bilibili.com/v/life/daily/?spm_id_from=333.5.b_6c6966655f6461696c79.2#/',
                                  new=1, autoraise=True)

    # 睡眠5秒
    # time.sleep(5)

    # 关闭chrome浏览器
    # os.system('taskkill /F /IM chrome.exe')
    time.sleep(1)
    pyautogui.size()
    print(pyautogui.size())
    # ————————————————打开指定网址——————
    # time.sleep(3)效果不行
    pyautogui.PAUSE = 1
    # pyautogui.scroll(-800)
    # pyautogui.click(x=287, y=231, clicks=1, interval=0.0, duration=0.0)
    pyautogui.click(x=457, y=921, clicks=1, interval=0.0, duration=0.0)

    # -----------打开第一个sp
    # pyautogui.scroll(-300)  # 向下滚动100
    # _____________

    while True:
        # 跳过可能会发生的TypeError: cannot unpack non-iterable NoneType object错误
        try:
            # 搜索点赞按钮
            img_find = pyautogui.locateOnScreen('0826.png')
            left, top, width, height = img_find

        except:
            pass
        if img_find:
            # 点击按钮中心
            time.sleep(2)
            pyautogui.click(pyautogui.center((left, top, width, height)))
            # 点击后停顿一下防止鼠标误点
            # time.sleep(1)
            t = random.randint(1, 9)  # 模拟用户点击,随机时间操作
            print(t)
            time.sleep(t)
            pyautogui.scroll(-600)  # 向下滚动100
            img_find2 = pyautogui.locateOnScreen('08262.png')
            left, top, width, height = img_find2
            # 点击按钮中心
            time.sleep(2)
            pyautogui.click(pyautogui.center((left, top, width, height)))
            # pyautogui.typewrite('支持UP,期待回访', interval=0.25)
            pyperclip.copy(random.choice(["支持UP,期待回访", "阿P的哲学支持UP,期待回访", "做UP不易,阿P的哲学来支持了"]))  # 先复制
            pyautogui.hotkey('ctrl', 'v')  # 再粘贴
            # 每次输入间隔0.25秒,输入Hello world!
            # 点击后停顿一下防止鼠标误点
            # time.sleep(1)
            t = random.randint(1, 9)  # 模拟用户点击,随机时间操作
            print(t)
            time.sleep(t)
            img_find3 = pyautogui.locateOnScreen('08263.png')
            left, top, width, height = img_find3
            # 点击按钮中心
            time.sleep(2)
            pyautogui.click(pyautogui.center((left, top, width, height)))
            # pyautogui.typewrite('支持UP,期待回访', interval=0.25)
            # 每次输入间隔0.25秒,输入Hello world!
            # 点击后停顿一下防止鼠标误点
            # time.sleep(1)
            t = random.randint(1, 9)  # 模拟用户点击,随机时间操作
            print(t)
            time.sleep(t)
            # pyautogui.PAUSE = 5
            # 记录点赞次数
            # print('成功点赞'+str(i)+'次')
            print('成功点赞' + str(rp) + '次')
            print('成功点赞')
            # i+=1
        else:
            break

    else:
        break

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值