• 2.如何实现使用VBS脚本程序对直播间自动评论


    前言:本文使用的是VBS脚本,实现了对繁星直播自动登录,自动进入房间并且自动评论。

    前提准备:把需要刷的评论放到mysql中,再使用vbs读出评论

    --------------------------------------------------------------------------------

    1.vbs实现连接mysql数据库并且读出数据

    首先本地或者远程有一个mysql,再者,需要下载mysql connector,下载链接http://dev.mysql.com/downloads/connector/odbc/

    或者去本人的网盘下载,具体根据mysql的版本来决定

    32位链接: http://pan.baidu.com/s/1jIHbCXo 密码: ge69

    64位链接: http://pan.baidu.com/s/1eSJlFA6 密码: ukwq

    下载安装之后配置

    方法如下:控制面板->管理工具

    ->ODBC数据源(选择合适位数)

    添加数据源

    编写配置:

    确定

    ------------------------------------------------------------------------------------------------------------

    具体代码为:

    set WshShell=WScript.CreateObject("WScript.Shell")
    Dim conn
    '连接数据库
    function connectMysql()
        strConn="dsn=mysql;driver={MySql ODBC 5.3 Unicode Driver};server=localhost;database=wechat;port=3306;uid=root;password=basketball"
        Set conn = CreateObject("adodb.connection")
        conn.Open strConn
        If conn.State = 0 Then
            MsgBox  "fail"
            WScript.quit 
        Else
            MsgBox  "success"
        End If
        connectMysql = conn
    End function
    
    '把数据库中的用户都读出来 
    Function readUser()
        connectMysql
        Set Rst =CreateObject("ADODB.Recordset")
        Dim user()
        Rst.open "select account,pwd from user",conn
        i=0
        While not Rst.eof
        Redim Preserve user(i,1)
        user(i,0)=Rst("account").value
        user(i,1)=Rst("pwd").value
        MsgBox user(i,0)
        MsgBox user(i,1)
        i = i+1
        Rst.movenext   
        wend
        Rst.close          '关闭记录集
        Set Rst=nothing    '释放对象
        conn.close         '关闭连接
        Set conn=nothing   '释放对象
        readUser = User
    End Function 
    
    '把数据库中的评论都读出来
    Function readRemark()
        connectMysql
        Set Rst =CreateObject("ADODB.Recordset")
        Dim myRemark()
        Rst.open "select remark from remark",conn
        i=0
        While not Rst.eof
        Redim Preserve myRemark(i)
        myRemark(i)=Rst("remark").value
        'MsgBox  myRemark(i)
        i = i+1
        Rst.movenext   
        wend
        Rst.close          '关闭记录集
        Set Rst=nothing    '释放对象
        conn.close         '关闭连接
        Set conn=nothing   '释放对象
        readRemark = myRemark
    End Function
    
    '把评论刷在直播间
    function login()
        '获取评论
        Remark = readRemark()
        User = readUser()
        for i=0 to UBound(User)
            Dim ie
            Set ie = CreateObject("InternetExplorer.Application")
            ie.navigate "http://fanxing.kugou.com/"
            Wscript.sleep 2000
            ie.document.getElementById("fxLogin").Click
            ie.document.getElementById("loginSdk_loginUserName").Value = User(i,0)
            ie.document.getElementById("loginSdk_loginPassWord").Value = user(i,1)
            ie.document.getElementById("loginSdk_loginBtn").Click
            Wscript.sleep 2000
            Set ie2 = CreateObject("InternetExplorer.Application")
            ie2.navigate "http://fanxing.kugou.com/1038049"
            Wscript.sleep 2000
            for j=0 to UBound(Remark) 
            Wscript.sleep 2000
            ie2.document.getElementById("inputChatMessage").Value = Remark(j)
            Wscript.sleep 2000
            ie2.document.getElementById("sendMessageButton").Click
            next
        next
    end function
    
    '关闭浏览器
    function closeWeb()
        Set ws = CreateObject("Wscript.Shell") 
        ws.run "taskkill /f /im 360se.exe",vbhide
    End Function
    
    '开始执行
    login
    Wscript.sleep 2000
    closeWeb
    Wscript.Quit

    以上代码结合起来即可实现自动登陆繁星并且实现自动评论,其中一些参数需要要实际情况自己填写。

    源码

    效果如下:

  • 相关阅读:
    vuejs cli3 env配置文件实践指南
    Nginx的rewrite(地址重定向)剖析
    什么是TCP粘包?怎么解决这个问题
    windows bat批处理语法简析
    BAT文件语法和技巧(bat文件的编写及使用)
    Asyncio之EventLoop笔记
    python struct的使用例子
    redis慢查询笔记
    redis基础操作概念等笔记
    Python实现Dijkstra算法
  • 原文地址:https://www.cnblogs.com/caimuqing/p/5772747.html
Copyright © 2020-2023  润新知