スーパー卵傑の自動スクリプト(3)は、奪分入団圧分機能に署名した.
13785 ワード
基礎はもうできた.残りの機能はすべて簡単です.データ分析でいいです.
まずモジュールにサインします.
分が00 or 30ならサインを打てばいいと判断.弾幕の重複を防ぐため、サイン後に現在の時間を加算します.
弾幕の影響を受けないようにサインしたので、スレッドを追加しました.
ポイントを奪う解決には2つの方法があり、1つ目はwiresharkでバッグをつかんで、贈り物を送るデータコードを知っています.プレゼントのデータを受け取ると、点数を奪う.(ただし生放送終了時に散点は無用)
第二に、誰かが弾幕を打って点数を奪ったのは、誰かが贈り物をしたことを示している.点数を奪う.
私は怠け者なので(生放送を見るのもタイプするのがおっくうなので)、2つ目を選びました.△弊害があります.例えば、「wsyjz 100」という仁兄の劣悪な脚本は、絶えず点数を取って、私の脚本も偏られて、彼と一緒に馬鹿な点数を出しました.だから、断固として彼を隠しました.
もう一つの問題は周波数の問題で、みんなは弾幕を集中して、相応のことをしていることを説明します.しかし、散発的な髪は、相手の遅延問題であることを示しています.無視できます.だから10秒以内に弾幕が現れる回数で判断します.
誰かが点数を奪うと3回も点数を奪う.
入団も採点と同じだ.
圧分はまず自分のポイントデータを取得します.
これは卵傑ポイントapiですhttp://api.xiaojie666.com/xiaojie/credit/query.do?nickName=
あとに自分のIDをつければいい
ここではrequest,re正規表現を用いてデータ中の積分を抽出する.
圧分は#1#2のほうがどちらを押しているかを見ます.この方面のデータの割合やアルゴリズムは,みんなで自分で変えればよい.
これで、簡単な基本的なスクリプトが完成します.しかし、まだ多くの機能が追加されていません.後でお話しします.
自分のネット上でsocketチュートリアル、seleniumチュートリアル、Threadマルチスレッドチュートリアル、re、xpath、beautifulsoup 4の使い方を深く理解したい.
wiresharkパケットでデータ分析、データ型処理を行います.△弾幕の少ない生中継室でバッグをつかむことをお勧めします.弾幕の多い生中継室では、それがどこなのか全然見つかりません.私は1622029でバッグを捕まえました.アナウンサーは美しくて、声が甘くて、性格がよくて、むやみに人をののしったことがありません.
次は、総手順です.
以前signモジュール内ではtimeの直接命名はできなかったのでminに変更しました.
自分のブラウザのクッキーパスを置き換えます.
nickName=に自分の闘魚IDを追加するには
親測は問題ないが、初心者は半日デバッグする予定だ.環境変数を構成するので、さまざまなモジュールをインストールするのも面倒です.
まずモジュールにサインします.
分が00 or 30ならサインを打てばいいと判断.弾幕の重複を防ぐため、サイン後に現在の時間を加算します.
def sign():
while 1:
time = time.strftime('%M', time.localtime())
if time == '00':
try:
dm = '# '+ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
except:
driver.refresh()
if time == '30':
try:
dm = '# '+ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
except:
driver.refresh()
time.sleep(50)
弾幕の影響を受けないようにサインしたので、スレッドを追加しました.
def main():
init()
t1 = Thread(target=get_dm)
t2 = Thread(target=keep_live)
t3 = Thread(target=sign)
t1.start()
t2.start()
t3.start()
if __name__ == '__main__':
main()
ポイントを奪う解決には2つの方法があり、1つ目はwiresharkでバッグをつかんで、贈り物を送るデータコードを知っています.プレゼントのデータを受け取ると、点数を奪う.(ただし生放送終了時に散点は無用)
第二に、誰かが弾幕を打って点数を奪ったのは、誰かが贈り物をしたことを示している.点数を奪う.
私は怠け者なので(生放送を見るのもタイプするのがおっくうなので)、2つ目を選びました.△弊害があります.例えば、「wsyjz 100」という仁兄の劣悪な脚本は、絶えず点数を取って、私の脚本も偏られて、彼と一緒に馬鹿な点数を出しました.だから、断固として彼を隠しました.
もう一つの問題は周波数の問題で、みんなは弾幕を集中して、相応のことをしていることを説明します.しかし、散発的な髪は、相手の遅延問題であることを示しています.無視できます.だから10秒以内に弾幕が現れる回数で判断します.
def get_dm():
pattern = re.compile(b'type@=chatmsg/.+?/nn@=(.+?)/txt@=(.+?)/.+?/level@=(.+?)/')
Grab_points_1 = Grab_points_2 = Grab_points_ALL = frequency =0
while 1:
buffer = b''
while 1:
recv_data = sk_client.recv(4096)
buffer += recv_data
if recv_data.endswith(b'\x00'):
break
for nn, txt, level in pattern.findall(buffer):
min = time.strftime('%M', time.localtime())
sec = time.strftime('%S', time.localtime())
try:
print("[lv.{:0<2}][{}]: {}".format(level.decode(), nn.decode(), txt.decode().strip()))
print("[lv.{:0<2}][{}]: {}".format(level.decode(), nn.decode(), txt.decode().strip()))
if nn.decode() == 'wsyjz100':
continue
if '9' in sec: # 10
Grab_points_1 = 0
Grab_points_2 = 0
Grab_points_ALL = 0
frequency = 0
if '# ' in txt.decode().strip():
frequency += 1
if frequency == 10:
for i in range(0, 3):
dm = '# '+ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
except UnicodeDecodeError as e:
print(e)
誰かが点数を奪うと3回も点数を奪う.
入団も採点と同じだ.
def get_dm():
pattern = re.compile(b'type@=chatmsg/.+?/nn@=(.+?)/txt@=(.+?)/.+?/level@=(.+?)/')
Grab_points_1 = Grab_points_2 = Grab_points_ALL = frequency = join = 0
while 1:
buffer = b''
while 1:
recv_data = sk_client.recv(4096)
buffer += recv_data
if recv_data.endswith(b'\x00'):
break
for nn, txt, level in pattern.findall(buffer):
min = time.strftime('%M', time.localtime())
sec = time.strftime('%S', time.localtime())
try:
print("[lv.{:0<2}][{}]: {}".format(level.decode(), nn.decode(), txt.decode().strip()))
if nn.decode() == 'wsyjz100':
continue
if '9' in sec: # 10
Grab_points_1 = 0
Grab_points_2 = 0
Grab_points_ALL = 0
frequency = 0
if '# ' in txt.decode().strip():
frequency += 1
if frequency == 10:
for i in range(0, 3):
dm = '# '+ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
if '# ' in txt.decode().strip():
join += 1
if join == 10:
dm = '# '
send_dm(dm)
except UnicodeDecodeError as e:
print(e)
圧分はまず自分のポイントデータを取得します.
これは卵傑ポイントapiですhttp://api.xiaojie666.com/xiaojie/credit/query.do?nickName=
あとに自分のIDをつければいい
ここではrequest,re正規表現を用いてデータ中の積分を抽出する.
credit = requests.get('http://api.xiaojie666.com/xiaojie/credit/query.do?nickName=')
credit.encoding = 'utf-8'
CREDIT = credit.text
pattern = '"credit":(.*?),"'
CREDIT = re.findall(pattern, CREDIT)# CREDIT list 。
CREDIT = int(CREDIT[0])# CREDIT int 。
圧分は#1#2のほうがどちらを押しているかを見ます.この方面のデータの割合やアルゴリズムは,みんなで自分で変えればよい.
def get_dm():
pattern = re.compile(b'type@=chatmsg/.+?/nn@=(.+?)/txt@=(.+?)/.+?/level@=(.+?)/')
Grab_points_1 = Grab_points_2 = Grab_points_ALL = frequency =0
while 1:
buffer = b''
while 1:
recv_data = sk_client.recv(4096)
buffer += recv_data
if recv_data.endswith(b'\x00'):
break
for nn, txt, level in pattern.findall(buffer):
min = time.strftime('%M', time.localtime())
sec = time.strftime('%S', time.localtime())
try:
print("[lv.{:0<2}][{}]: {}".format(level.decode(), nn.decode(), txt.decode().strip()))
if nn.decode() == 'wsyjz100':
continue
if '9' in sec: # 10
Grab_points_1 = 0
Grab_points_2 = 0
Grab_points_ALL = 0
if '# ' in txt.decode().strip():
frequency += 1
if frequency == 10:
for i in range(0, 3):
dm = '# '+ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
if '# ' in txt.decode().strip():
join += 1
if join == 10:
dm = '# '
send_dm(dm)
if '#1' in txt.decode().strip() and '0' in txt.decode().strip():
Grab_points_1 += 1
Grab_points_ALL += 1
if '#2' in txt.decode().strip() and '0' in txt.decode().strip():
Grab_points_2 += 1
Grab_points_ALL += 1
if Grab_points_ALL ==30:
if Grab_points_1 > Grab_points_2:
dm = '#1' + str(CREDIT/10)
send_dm(dm)
else:
dm = '#2' + str(CREDIT/10)
send_dm(dm)
except UnicodeDecodeError as e:
print(e)
これで、簡単な基本的なスクリプトが完成します.しかし、まだ多くの機能が追加されていません.後でお話しします.
自分のネット上でsocketチュートリアル、seleniumチュートリアル、Threadマルチスレッドチュートリアル、re、xpath、beautifulsoup 4の使い方を深く理解したい.
wiresharkパケットでデータ分析、データ型処理を行います.△弾幕の少ない生中継室でバッグをつかむことをお勧めします.弾幕の多い生中継室では、それがどこなのか全然見つかりません.私は1622029でバッグを捕まえました.アナウンサーは美しくて、声が甘くて、性格がよくて、むやみに人をののしったことがありません.
次は、総手順です.
以前signモジュール内ではtimeの直接命名はできなかったのでminに変更しました.
自分のブラウザのクッキーパスを置き換えます.
nickName=に自分の闘魚IDを追加するには
親測は問題ないが、初心者は半日デバッグする予定だ.環境変数を構成するので、さまざまなモジュールをインストールするのも面倒です.
import re
import socket
import struct
import time
from threading import Thread
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import requests
sk_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# tcp
host = socket.gethostbyname("openbarrage.douyutv.com")
#
port = 8601
#
sk_client.connect((host, port))
#
driverOptions = webdriver.ChromeOptions()
driverOptions.add_argument(r"user-data-dir=C:\Users\86185\AppData\Local\Google\Chrome\User Data")
# cookie , user data 。
# driverOptions.add_argument('-headless')
# headless ,70 。
driver = webdriver.Chrome(options=driverOptions)
driver.get('https://www.douyu.com/74751') # ,url
credit = requests.get('http://api.xiaojie666.com/xiaojie/credit/query.do?nickName=')
credit.encoding = 'utf-8'
CREDIT = credit.text
pattern = '"credit":(.*?),"'
CREDIT = re.findall(pattern, CREDIT) # CREDIT list 。
CREDIT = int(CREDIT[0]) # CREDIT int 。
def send_msg(msg): # , 。
content = msg.encode()
length = len(content) + 8
code = 689
head = struct.pack('i', length) + struct.pack('i', length) + struct.pack('i', code)
try:
sk_client.sendall(head + content)
except:
time.sleep(2)
def send_dm(dm):
DM = str(dm)
try:
driver.find_element_by_xpath("//textarea[@class='ChatSend-txt ']").clear()
#
driver.find_element_by_xpath("//textarea[@class='ChatSend-txt ']").send_keys(DM)
#
time.sleep(1)
driver.find_element_by_xpath("//textarea[@class='ChatSend-txt ']").send_keys(Keys.ENTER)
#
time.sleep(9)
except:
pass
def init(): #
msg_login = 'type@=loginreq/roomid@=74751/\x00'
# roomid@=()/
send_msg(msg_login)
time.sleep(1)
msg_join = 'type@=joingroup/rid@=74751/gid@=-9999/\x00'
#
send_msg(msg_join)
def get_dm():
pattern = re.compile(b'type@=chatmsg/.+?/nn@=(.+?)/txt@=(.+?)/.+?/level@=(.+?)/')
Grab_points_1 = Grab_points_2 = Grab_points_ALL = frequency = join = 0
while 1:
buffer = b''
while 1:
recv_data = sk_client.recv(4096)
buffer += recv_data
if recv_data.endswith(b'\x00'):
break
for nn, txt, level in pattern.findall(buffer):
min = time.strftime('%M', time.localtime())
sec = time.strftime('%S', time.localtime())
try:
print("[lv.{:0<2}][{}]: {}".format(level.decode(), nn.decode(), txt.decode().strip()))
if nn.decode() == 'wsyjz100':
continue
if '9' in sec: # 10
Grab_points_1 = 0
Grab_points_2 = 0
Grab_points_ALL = 0
if '# ' in txt.decode().strip():
frequency += 1
if frequency == 10:
for i in range(0, 3):
dm = '# ' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
if '# ' in txt.decode().strip():
join += 1
if join == 10:
dm = '# '
send_dm(dm)
if '#1' in txt.decode().strip() and '0' in txt.decode().strip():
Grab_points_1 += 1
Grab_points_ALL += 1
if '#2' in txt.decode().strip() and '0' in txt.decode().strip():
Grab_points_2 += 1
Grab_points_ALL += 1
if Grab_points_ALL == 30:
if Grab_points_1 > Grab_points_2:
dm = '#1' + str(CREDIT / 10)
send_dm(dm)
else:
dm = '#2' + str(CREDIT / 10)
send_dm(dm)
except UnicodeDecodeError as e:
print(e)
def keep_live(): # ,
while True:
time.sleep(15)
msg_keep = 'type@=mrkl/\x00'
send_msg(msg_keep)
def sign():
while 1:
min = time.strftime('%M', time.localtime())
if min == '00':
try:
dm = '# ' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
except:
driver.refresh()
if min == '30':
try:
dm = '# ' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
send_dm(dm)
except:
driver.refresh()
time.sleep(50)
def main():
init() #
t1 = Thread(target=get_dm) #
t2 = Thread(target=keep_live) #
t3 = Thread(target=sign) #
t1.start() #
t2.start()
t3.start()
if __name__ == '__main__':
main()