临时提交

This commit is contained in:
zw
2025-08-12 18:53:06 +08:00
parent 747126f1f8
commit 1ce16cff46
5 changed files with 102 additions and 31 deletions

View File

@@ -11,7 +11,13 @@ anchorList: list[AnchorModel] = []
# 线程锁 # 线程锁
anchorListLock = threading.Lock() anchorListLock = threading.Lock()
# 账号token # 账号token
accountToken = None accountToken = "xHtil6YiAH2QxDgAYVwCfVafx7xkOoeHVfiVgfqfdwe88KZW5jbRsjDS9ZGFILJSGuXTu4V29MgHaYnO3jy2dxpqs77DtAQGnW6AlJ7NItSWSmSaoKRXtCYEng9KlCft"
# 打招呼数据
prologueList = []
# 评论列表
commentsList = []
# 安全删除数据 # 安全删除数据
def removeModelFromAnchorList(model: AnchorModel): def removeModelFromAnchorList(model: AnchorModel):
@@ -24,3 +30,4 @@ def addModelToAnchorList(models: list[Dict[str, Any]]):
for dic in models: for dic in models:
obj = AnchorModel.dictToModel(dic) obj = AnchorModel.dictToModel(dic)
anchorList.append(obj) anchorList.append(obj)

View File

@@ -124,7 +124,7 @@ class ControlUtils(object):
# 获取关注按钮 # 获取关注按钮
@classmethod @classmethod
def clickFollowButton(cls, session: Client): def clickFollowButton(cls, session: Client):
followButton = session.xpath('//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[2]/Other[2]/Other[1]/Other[1]/Other[3]/Other[1]/Other[1]/Button[1]') followButton = session.xpath("//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[2]/Other[2]/Other[1]/Other[1]/Other[3]/Other[1]/Other[1]/Button[1]")
if followButton.exists: if followButton.exists:
print("找到了") print("找到了")
followButton.click() followButton.click()

View File

@@ -1,7 +1,45 @@
from Entity.Variables import accountToken import requests
from Entity.Variables import accountToken, prologueList
# BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
BaseUrl = "http://192.168.1.174:8101/api/common/"
class Requester(): class Requester():
comment = "comment"
prologue = "prologue"
@classmethod @classmethod
def printToken(cls): def requestComments(cls):
print(accountToken) headers = {
"vvtoken": accountToken,
}
url = BaseUrl + cls.prologue
result = requests.get(headers=headers, url=url)
json = result.json()
data = json.get("data")
for i in data:
prologueList.append(i)
# 翻译
@classmethod
def translation(cla, msg, country="英国"):
parame = {
"msg":msg,
"country":country,
}
url = "http://ai.zhukeping.com/translation"
result = requests.request(url=url, json=parame, method="POST")
json = result.json()
data = json.get("data")
print(data)
return data
# ai聊天
@classmethod
def chatToAi(cls, param):
url = "http://ai.zhukeping.com/chat"
result = requests.request(url=url, json=param, method="POST")
json = result.json()
data = json.get("data", {})
return data

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 945 KiB

View File

@@ -7,7 +7,8 @@ import os
from Utils.AiUtils import AiUtils from Utils.AiUtils import AiUtils
from Utils.ControlUtils import ControlUtils from Utils.ControlUtils import ControlUtils
from Utils.LogManager import LogManager from Utils.LogManager import LogManager
from Entity.Variables import anchorList, removeModelFromAnchorList from Entity.Variables import anchorList, removeModelFromAnchorList, prologueList
from Utils.Requester import Requester
# 脚本管理类 # 脚本管理类
@@ -182,7 +183,6 @@ class ScriptManager():
def greetNewFollowers(self, udid, needReply, event): def greetNewFollowers(self, udid, needReply, event):
client = wda.USBClient(udid) client = wda.USBClient(udid)
session = client.session() session = client.session()
session.appium_settings({"snapshotMaxDepth": 15})
# 先关闭Tik Tok # 先关闭Tik Tok
ControlUtils.closeTikTok(session, udid) ControlUtils.closeTikTok(session, udid)
@@ -192,9 +192,11 @@ class ScriptManager():
ControlUtils.openTikTok(session, udid) ControlUtils.openTikTok(session, udid)
time.sleep(3) time.sleep(3)
# 设置查找深度
session.appium_settings({"snapshotMaxDepth": 15})
# 点击搜索按钮 # 点击搜索按钮
ControlUtils.clickSearch(session) ControlUtils.clickSearch(session)
# 搜索 # 查找输入
input = session.xpath('//XCUIElementTypeSearchField') input = session.xpath('//XCUIElementTypeSearchField')
# 如果找到了输入框,就点击并且输入内容 # 如果找到了输入框,就点击并且输入内容
input.click() input.click()
@@ -203,28 +205,22 @@ class ScriptManager():
# 返回上一步 # 返回上一步
def goBack(): def goBack():
ControlUtils.clickBack(session) # ControlUtils.clickBack(session)
# 搜索框 client.swipe(5,120, 50, 120)
input = session.xpath('//XCUIElementTypeSearchField')
# 如果找到了输入框,就点击并且输入内容
input.click()
# 稍作停顿
time.sleep(1)
# 删除数据 # 删除数据
removeModelFromAnchorList(anchor) removeModelFromAnchorList(anchor)
# 循环条件。1、 循环关闭 2、 数据处理完毕 # 循环条件。1、 循环关闭 2、 数据处理完毕
while not event.is_set() or len(anchorList) > 0: while not event.is_set() or len(anchorList) > 0:
# 获取一个主播 # 获取一个主播
anchor = anchorList[0] anchor = anchorList[0]
aid = anchor.anchorId aid = anchor.anchorId
anchorCountry = anchor.country
try: input.clear_text()
input.clear_text()
except Exception as e:
print(e)
time.sleep(2) time.sleep(2)
# 输入主播id # 输入主播id
input.set_text(aid + "\n") input.set_text(aid + "\n")
@@ -251,8 +247,8 @@ class ScriptManager():
# 观看主播视频 # 观看主播视频
def viewAnchorVideo(): def viewAnchorVideo():
print("开始查看视频") print("开始查看视频")
count = 5 count = 2
while count > 1: while count > 0:
print("条件满足,继续查看") print("条件满足,继续查看")
img = client.screenshot() img = client.screenshot()
time.sleep(1) time.sleep(1)
@@ -277,6 +273,7 @@ class ScriptManager():
time.sleep(10) time.sleep(10)
client.swipe_up() client.swipe_up()
if count == 1: if count == 1:
client.swipe_right()
break break
# 点击第一个视频后的逻辑 # 点击第一个视频后的逻辑
@@ -285,32 +282,61 @@ class ScriptManager():
session.appium_settings({"snapshotMaxDepth": 5}) session.appium_settings({"snapshotMaxDepth": 5})
print("重新设置了匹配深度") print("重新设置了匹配深度")
viewAnchorVideo() viewAnchorVideo()
time.sleep(2)
print("视频看完了")
session.appium_settings({"snapshotMaxDepth": 25})
# 视频看完需要点关注。 # 视频看完需要点关注。
ControlUtils.clickFollowButton(session) r = ControlUtils.clickFollowButton(session)
time.sleep(1) if r == False:
ControlUtils.clickFollowButton(session) print("执行失败了")
# 发送一条信息
time.sleep(2)
ControlUtils.clickFollowButton(session)
time.sleep(2)
# 查找聊天界面中的输入框节点
chatInput = session.xpath("//*[className='XCUIElementTypeTextView']") chatInput = session.xpath("//*[className='XCUIElementTypeTextView']")
if chatInput.exists: if chatInput.exists:
print("找到了") print("找到了")
# 准备发送一条信息
chatInput.click()
time.sleep(2)
# text = random.choice(prologueList)
# msg = Requester.translation(text, anchorCountry)
chatInput.set_text("哈哈哈" + "\n")
time.sleep(1)
client.swipe_right()
time.sleep(1)
client.swipe_right()
time.sleep(2)
else: else:
print("没找到") print("没找到")
client.swipe_right()
time.sleep(1)
client.swipe_right()
time.sleep(2)
break
# 清除数据 # 清除数据
removeModelFromAnchorList(anchor) removeModelFromAnchorList(anchor)
# 流程结束 # 流程结束
client.swipe_left() # client.swipe_right()
time.sleep(1) # time.sleep(1)
else: else:
print("获取该主播第一个视频失败") print("获取该主播第一个视频失败")
goBack() goBack()
def test(self, udid):
client = wda.USBClient(udid)
client.swipe_right()
# manager = ScriptManager() manager = ScriptManager()
manager.test("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
# manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa") # manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")