From 4a17c6f7ee91a2a06acb6847da8f6f7e33e0ba42 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 3 Nov 2025 18:30:51 +0800 Subject: [PATCH] fewfwe --- weex交易/30分钟仿盘交易.py | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/weex交易/30分钟仿盘交易.py b/weex交易/30分钟仿盘交易.py index ea76e09..38f953f 100644 --- a/weex交易/30分钟仿盘交易.py +++ b/weex交易/30分钟仿盘交易.py @@ -1,9 +1,11 @@ import datetime +import re import time import hmac import hashlib import base64 import time +from bs4 import BeautifulSoup import requests import json import requests @@ -238,16 +240,43 @@ class WeexTransaction: if current_minute in [0, 30]: # 判断是否是 新的30分钟了 - if self.page.ele('x://section[text()="仓位(1)"]', timeout=5): - text = self.page.ele( - 'x://*[@id="tradeLimitContainerJS"]/div[2]/div/div[1]/div/div/div/div[5]/div/div/div[2]').text - if "ETH/SUSDT 多" in text: - self.start = 1 - elif "ETH/SUSDT 空" in text: - self.start = -1 + + # 要匹配的目标文本 + target_text = "仓位(1)" + + # 去除目标文本中的空白字符 + cleaned_target_text = re.sub(r'\s', '', target_text) + + # 创建 BeautifulSoup 对象 + soup = BeautifulSoup(self.page.html, 'html.parser') + + # 遍历所有标签的文本内容 + for tag in soup.find_all(): + tag_text = tag.get_text() + # 去除标签文本中的空白字符 + cleaned_tag_text = re.sub(r'\s', '', tag_text) + if cleaned_target_text in cleaned_tag_text: + text = self.page.ele( + 'x://*[@id="tradeLimitContainerJS"]/div[2]/div/div[1]/div/div/div/div[5]/div/div/div[2]').text + if "ETH/SUSDT 多" in text: + self.start = 1 + break + elif "ETH/SUSDT 空" in text: + self.start = -1 + break else: self.start = 0 + # if self.page.html: + # text = self.page.ele( + # 'x://*[@id="tradeLimitContainerJS"]/div[2]/div/div[1]/div/div/div/div[5]/div/div/div[2]').text + # if "ETH/SUSDT 多" in text: + # self.start = 1 + # elif "ETH/SUSDT 空" in text: + # self.start = -1 + # else: + # self.start = 0 + new_price_datas = self.get_price() if new_price_datas: logger.success("获取最新交易价格成功!!!")