1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 2.如何实现使用VBS脚本程序对直播间自动评论

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

时间:2018-11-09 18:00:50

相关推荐

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

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

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

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

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

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

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

32位链接: /s/1jIHbCXo 密码: ge69

64位链接: /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 strConnIf conn.State = 0 ThenMsgBox "fail"WScript.quit ElseMsgBox "success"End IfconnectMysql = connEnd function'把数据库中的用户都读出来 Function readUser()connectMysqlSet Rst =CreateObject("ADODB.Recordset")Dim user()Rst.open "select account,pwd from user",conni=0While not Rst.eofRedim Preserve user(i,1)user(i,0)=Rst("account").valueuser(i,1)=Rst("pwd").valueMsgBox user(i,0)MsgBox user(i,1)i = i+1Rst.movenext wendRst.close'关闭记录集Set Rst=nothing '释放对象conn.close '关闭连接Set conn=nothing '释放对象readUser = UserEnd Function '把数据库中的评论都读出来Function readRemark()connectMysqlSet Rst =CreateObject("ADODB.Recordset")Dim myRemark()Rst.open "select remark from remark",conni=0While not Rst.eofRedim Preserve myRemark(i)myRemark(i)=Rst("remark").value'MsgBox myRemark(i)i = i+1Rst.movenext wendRst.close'关闭记录集Set Rst=nothing '释放对象conn.close '关闭连接Set conn=nothing '释放对象readRemark = myRemarkEnd Function'把评论刷在直播间function login()'获取评论Remark = readRemark()User = readUser()for i=0 to UBound(User)Dim ieSet ie = CreateObject("InternetExplorer.Application")ie.navigate "/"Wscript.sleep 2000ie.document.getElementById("fxLogin").Clickie.document.getElementById("loginSdk_loginUserName").Value = User(i,0)ie.document.getElementById("loginSdk_loginPassWord").Value = user(i,1)ie.document.getElementById("loginSdk_loginBtn").ClickWscript.sleep 2000Set ie2 = CreateObject("InternetExplorer.Application")ie2.navigate "/1038049"Wscript.sleep 2000for j=0 to UBound(Remark) Wscript.sleep 2000ie2.document.getElementById("inputChatMessage").Value = Remark(j)Wscript.sleep 2000ie2.document.getElementById("sendMessageButton").Clicknextnextend function'关闭浏览器function closeWeb()Set ws = CreateObject("Wscript.Shell") ws.run "taskkill /f /im 360se.exe",vbhideEnd Function'开始执行loginWscript.sleep 2000closeWebWscript.Quit

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

源码

效果如下:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。