117 lines
4.5 KiB
Python
117 lines
4.5 KiB
Python
# import traceback
|
|
from email.mime.text import MIMEText
|
|
from smtplib import SMTP_SSL
|
|
|
|
from helium import *
|
|
from selenium.webdriver import ChromeOptions
|
|
|
|
|
|
class Chrome(object):
|
|
def __init__(self, mobile=True, headless=True):
|
|
self.mobile_emulation = {'deviceName': 'iPad Mini'}
|
|
self.mobile = mobile
|
|
self.headless = headless
|
|
|
|
|
|
def __enter__(self):
|
|
chrome_options = ChromeOptions()
|
|
chrome_options.add_argument('--no-sandbox')
|
|
if self.headless:
|
|
chrome_options.add_argument('--headless')
|
|
if self.mobile:
|
|
chrome_options.add_experimental_option("mobileEmulation", self.mobile_emulation)
|
|
chrome_options.add_argument('user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"')
|
|
start_chrome("https://youdian.jindianle.com/", options=chrome_options)
|
|
click(Text("您尚未登录,点击登录"))
|
|
click(Text("密码登录"))
|
|
write("15359827092", into="请输入手机号")
|
|
write("c113w927j", into="请输入6-12位数字或字母")
|
|
click(Button("登 录"))
|
|
# 进入页面先点击关闭弹窗按钮
|
|
_close = S('//*[@id="vue2_el"]/div/div[10]/div/p')
|
|
click(_close)
|
|
return self
|
|
|
|
def __exit__(self, type, value, trace):
|
|
kill_browser()
|
|
print("type: " + type + ", value = " + value)
|
|
|
|
|
|
def balance(self):
|
|
#店内账本
|
|
click(Text("店内账本"))
|
|
moneynum = S('//span[contains(@class, "gray3") and contains(@class, "moneynum")]')
|
|
wait_until(moneynum.exists)
|
|
if moneynum is not None:
|
|
balance = moneynum.web_element.text
|
|
print(f"金额还剩:{balance}")
|
|
else:
|
|
print("元素未找到")
|
|
# 回退
|
|
back = S('#vue2_el > header > div.back > a')
|
|
click(back)
|
|
|
|
def pls(self, result=[]):
|
|
# 点击排列三
|
|
_pls = S('//*[@id="vue2_el"]/div/section/div[6]/div[4]/div[3]')
|
|
wait_until(_pls.exists)
|
|
click(_pls)
|
|
zx = Text('组选')
|
|
if not zx.exists:
|
|
wait_until(zx.exists)
|
|
click(zx)
|
|
# 普通投注-> 取消组3
|
|
# result = ['258', '357', '069', '168', '078', '267', '159', '339', '177', '366']
|
|
for index, item in enumerate(result):
|
|
if len(set(item)) == 3:
|
|
click(Text('普通投注'))
|
|
for i in item:
|
|
ball_line = S(f'//*[@id="body"]/section/div[3]/div[2]/ul/li[{int(i) + 1}]/p[1]')
|
|
if ball_line.exists:
|
|
print(ball_line.web_element.text)
|
|
click(ball_line)
|
|
else:
|
|
print(f"{i}不存在")
|
|
group3 = Text("组3")
|
|
if not group3.exists:
|
|
wait_until(group3.exists)
|
|
click(group3)
|
|
else:
|
|
click(Text('组3单式'))
|
|
if item[0] == item[1]:
|
|
double_ball = S(f'//*[@id="body"]/section/div[3]/div[1]/div[2]/ul/li[{int(item[0]) + 1}]/p')
|
|
single_ball = S(f'//*[@id="body"]/section/div[3]/div[2]/div[2]/ul/li[{int(item[2]) + 1}]/p')
|
|
else:
|
|
double_ball = S(f'//*[@id="body"]/section/div[3]/div[1]/div[2]/ul/li[{int(item[2]) + 1}]/p')
|
|
single_ball = S(f'//*[@id="body"]/section/div[3]/div[2]/div[2]/ul/li[{int(item[0]) + 1}]/p')
|
|
click(double_ball)
|
|
click(single_ball)
|
|
print(f"{index}: {item}")
|
|
next_step = Text("下一步")
|
|
if not next_step.exists:
|
|
wait_until(next_step.exists)
|
|
click(next_step)
|
|
if index + 1 != len(result):
|
|
wait_until(Text("+继续添加").exists)
|
|
click(Text("+继续添加"))
|
|
#div.mult_numkeyboard > ul > li:nth-child(1) > p
|
|
#div.mult_numkeyboard > ul > li:nth-child(2) > p
|
|
#div.mult_numkeyboard > ul > li:nth-child(11) > p
|
|
save = Text("保存")
|
|
if not save.exists:
|
|
wait_until(save.exists)
|
|
click(save)
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
back_2 = S('div.back')
|
|
if not back_2.exists:
|
|
wait_until(back_2.exists)
|
|
click(back_2)
|
|
|
|
|
|
|
|
with Chrome(headless=False) as chrome:
|
|
chrome.balance()
|
|
chrome.pls(result = ['258', '357', '069', '168', '078']) |