Fetch the repository succeeded.
This action will force synchronization from Nianwei/抖音弹幕无人直播游戏弹幕获取源码, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
import json
import requests
from google.protobuf.json_format import MessageToDict
import base64
from test_pb2 import *
import mitmproxy.http
from bs4 import BeautifulSoup
import urllib.parse
import emoji
import configparser
def get_html(data, cont, leixin):
html4 = requests.post("https://www.douyin.com/user/" + data)
soup = BeautifulSoup(html4.text, 'lxml')
shuju = soup.find("script", type="application/json").text
shuju1 = json.loads(urllib.parse.unquote(shuju),strict=False)
mingzi = shuju1['37']['user']['user']['nickname']
uid1 = shuju1['37']['user']['user']['secUid']
zongfensi = shuju1['37']['user']['user']['mplatformFollowersCount']
share = shuju1['37']['user']['user']['shareQrcodeUrl']
guanzhu = shuju1['37']['user']['user']['followingCount']
userid = shuju1['37']['user']['user']['uniqueId']
if leixin == 1:
file = open("ax.txt", 'a',encoding='utf8')
text = str(str(emoji.demojize(mingzi)) + "====" + str(uid1) + "====" + str(zongfensi) + "====" + str(
share) + "====" + str(guanzhu) + "====" + str(userid) + "====" + str(cont))
file.write(text + '\n')
file.close()
elif leixin == 2:
file = open("ax.txt", 'a',encoding='utf8')
text = str(str(emoji.demojize(mingzi)) + "====" + str(uid1) + "====" + str(zongfensi) + "====" + str(
share) + "====" + str(guanzhu) + "====" + str(userid) + "====" + str(cont))
file.write(text + '\n')
file.close()
elif leixin == 3:
file = open("ax.txt", 'a',encoding='utf8')
text = str(str(emoji.demojize(mingzi)) + "====" + str(uid1) + "====" + str(zongfensi) + "====" + str(
share) + "====" + str(guanzhu) + "====" + str(userid) + "====" + str(cont))
file.write(text + '\n')
file.close()
elif leixin == 4:
file = open("ax.txt", 'a',encoding='utf8')
text = str(str(emoji.demojize(mingzi)) + "====" + str(uid1) + "====" + str(zongfensi) + "====" + str(
share) + "====" + str(guanzhu) + "====" + str(userid) + "====" + str(emoji.demojize(cont)))
file.write(text + '\n')
file.close()
def on_message(data):
cf = configparser.ConfigParser()
cf.read("config.ini")
danmu_resp = test()
danmu_resp.ParseFromString(data)
message = MessageToDict(danmu_resp, preserving_proto_field_name=True)
for message in message['message']:
method = message["method"]
payload = bytes(base64.b64decode(message["payload"].encode()))
if method == "WebcastMemberMessage":
member_message = WebcastMemberMessage()
member_message.ParseFromString(payload)
obj1 = MessageToDict(member_message, preserving_proto_field_name=True)
val = cf.getint("config", "room")
if val == 1:
print("欢迎:" + obj1['user'][0]['nickname'] + "加入直播间"+"---------")
get_html(obj1['user'][0]['secUid'], "加入直播间", 1)
elif val == 0:
print("欢迎:" + obj1['user'][0]['nickname'] + "加入直播间" )
elif method == "WebcastGiftMessage":
member_message3 = WebcastGiftMessage()
member_message3.ParseFromString(payload)
obj3 = MessageToDict(member_message3, preserving_proto_field_name=True)
jiexi2 = obj3
print(jiexi2['common'][0]['describe'])
val = cf.getint("config", "gif")
if val == 1:
get_html(jiexi2['user'][0]['secUid'], "礼物消息", 2)
print(jiexi2['user'][0]['nickname'])
elif val==0:
print(jiexi2['user'][0]['nickname'])
elif method == "WebcastLikeMessage":
member_message4 = WebcastLikeMessage()
member_message4.ParseFromString(payload)
obj4 = MessageToDict(member_message4, preserving_proto_field_name=True)
jiexi = obj4
val = cf.getint("config", "like")
if val == 1:
get_html(jiexi['user'][0]['secUid'], "点赞消息", 3)
print(jiexi['user'][0]['nickname'] + "点赞了主播")
elif val==0:
print(jiexi['user'][0]['nickname'] + "点赞了主播")
elif method == "WebcastChatMessage":
member_message5 = WebcastChatMessage()
member_message5.ParseFromString(payload)
obj5 = MessageToDict(member_message5, preserving_proto_field_name=True)
jiexi1 = obj5
val = cf.getint("config", "chat")
if val == 1:
get_html(jiexi1['user'][0]['secUid'], jiexi1['content'], 4)
print(jiexi1['user'][0]['nickname'] + ":" + jiexi1['content'] )
elif val ==0 :
print(jiexi1['user'][0]['nickname'] + ":" + jiexi1['content'] )
class Counter:
def response(self, flow: mitmproxy.http.HTTPFlow):
if flow.request.host == "live.douyin.com":
data = flow.response.content
on_message(data)
addons = [
Counter()
]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。