0


基于selenium工具刷b站播放量(请谨慎使用)

基于selenium工具刷b站播放量(请谨慎使用)

from selenium import webdriver
import time
import random

# 打开B站视频
url =input("url:")'''
if url == "":
    url = 'https://www.bilibili.com/video/BV1K64y1574T'
'''for i inrange(50):# 设置Chrome驱动器路径# chromedriver下载地址:https://googlechromelabs.github.io/chrome-for-testing/
    driver_path ='C:\chromedriver.exe'# 设置浏览器选项
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument("log-level=3")# 打开浏览器
    browser = webdriver.Chrome(executable_path=driver_path, options=chrome_options)
    browser.get(url)
    time.sleep(random.uniform(4,10))try:# 获取视频名video-title
        name = browser.find_element_by_class_name('video-title').text
        print(f'当前视频:{name}')# 获取当前播放量
        play_count = browser.find_element_by_class_name('view').text
        print(f'当前播放量:{play_count}')# 点击播放按钮
        play_button = browser.find_element_by_class_name('bpx-player-state-wrap')
        play_button.click()except:pass
    time.sleep(random.uniform(20,40))# 关闭浏览器
    browser.quit()
    time.sleep(random.uniform(4,10))

selenium4.10后改版

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
import random

# selenium4.10变化 https://zhuanlan.zhihu.com/p/645995993 https://blog.csdn.net/qq_51976555/article/details/125667926# 打开B站视频
url =input("url:")'''
if url == "":
    url = 'https://www.bilibili.com/video/BV1K64y1574T'
'''for i inrange(50):# 设置Chrome驱动器路径# chromedriver下载地址:https://googlechromelabs.github.io/chrome-for-testing/
    driver_path ='C:\chromedriver.exe'# 设置浏览器选项
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument("log-level=3")# 打开浏览器
    service = Service(driver_path)
    browser = webdriver.Chrome(service=service, options=chrome_options)
    browser.get(url)
    time.sleep(random.uniform(4,10))try:# 获取视频名video-title
        name = browser.find_element(By.CLASS_NAME,'video-title').text
        print(f'当前视频:{name}')# 获取当前播放量
        play_count = browser.find_element(By.CLASS_NAME,'view').text
        print(f'当前播放量:{play_count}')# 点击播放按钮
        play_button = browser.find_element(By.CLASS_NAME,'bpx-player-state-wrap')
        play_button.click()except:pass
    time.sleep(random.uniform(20,40))# 关闭浏览器
    browser.quit()
    time.sleep(random.uniform(4,10))

本文转载自: https://blog.csdn.net/weixin_44476410/article/details/134866746
版权归原作者 浪速之星 所有, 如有侵权,请联系我们删除。

“基于selenium工具刷b站播放量(请谨慎使用)”的评论:

还没有评论