This commit is contained in:
Administrator
2025-11-10 16:46:11 +08:00
parent 87169817e2
commit 97ec1b7c7e
3 changed files with 27 additions and 2 deletions

Binary file not shown.

View File

@@ -165,12 +165,37 @@ class WeexTransaction:
return False
def remove_tags_and_spaces(self,html):
# 创建 BeautifulSoup 对象
soup = BeautifulSoup(html, 'html.parser')
# 获取去除标签后的文本
text = soup.get_text()
# 去除所有空格
text = text.replace(" ", "")
return text
def to_do_page(self):
# self.page.get("https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT")
self.mn_tab.ele('x://*[contains(text(), "市价")]', timeout=15).click()
time.sleep(1)
self.mn_tab.ele('x://input[@placeholder="请输入数量"]').input(1600)
html_text = self.remove_tags_and_spaces(html=self.mn_tab.html)
# 定义正则表达式模式,用于匹配包含逗号和小数点的数值
pattern = r'委托可用([\d,]+)\.\d+SUSDT'
# 使用 re.search 方法查找匹配项
match = re.search(pattern, html_text)
number = ""
if match:
# 提取匹配到的数值字符串
number_str = match.group().replace(',', '')
# 将提取的字符串转换为浮点数
number = float(number_str)
if not number:
return
self.mn_tab.ele('x://input[@placeholder="请输入数量"]').input(number/10)
time.sleep(1)
if self.direction == "long" and not self.start:

View File

@@ -279,7 +279,7 @@ class WeexTransaction:
res = self.mn_tab.listen.wait(timeout=15) # 等待并获取一个数据包
if res:
self.weex_headers = res.request.headers
self.weex_headers = dict(res.request.headers)
self.session.headers.update(self.weex_headers)
self.mn_tab.close()