266 lines
10 KiB
Python
266 lines
10 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)
|
|
_close = S('p.close')
|
|
if _close.exists:
|
|
click(_close)
|
|
return self
|
|
|
|
def __exit__(self, type, value, trace):
|
|
kill_browser()
|
|
|
|
|
|
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 plw(self, result=[], multiple=1, save_result=True):
|
|
"""
|
|
排列五
|
|
"""
|
|
_plw = S('p.lottname.p5')
|
|
wait_until(_plw.exists)
|
|
click(_plw)
|
|
for index, item in enumerate(result):
|
|
ten_thousand_ball = S(f'//*[@id="body"]/section/div[3]/div[1]/div[2]/ul/li[{int(item[0]) + 1}]/p')
|
|
if ten_thousand_ball.exists:
|
|
click(ten_thousand_ball)
|
|
thousand_ball = S(f'//*[@id="body"]/section/div[3]/div[2]/div[2]/ul/li[{int(item[1]) + 1}]/p')
|
|
if thousand_ball.exists:
|
|
click(thousand_ball)
|
|
hundred_ball = S(f'//*[@id="body"]/section/div[3]/div[3]/div[2]/ul/li[{int(item[2]) + 1}]/p')
|
|
if hundred_ball.exists:
|
|
click(hundred_ball)
|
|
ten_ball = S(f'//*[@id="body"]/section/div[3]/div[4]/div[2]/ul/li[{int(item[3]) + 1}]/p')
|
|
if ten_ball.exists:
|
|
click(ten_ball)
|
|
single_ball = S(f'//*[@id="body"]/section/div[3]/div[5]/div[2]/ul/li[{int(item[4]) + 1}]/p')
|
|
if single_ball.exists:
|
|
click(single_ball)
|
|
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("+继续添加"))
|
|
print(f"直选, index:{index}, item:{item}")
|
|
# 倍数
|
|
if multiple > 0:
|
|
for i in range(multiple - 1):
|
|
click(Text("+"))
|
|
if save_result: # 是否保存
|
|
save = Text("保存")
|
|
if not save.exists:
|
|
wait_until(save.exists)
|
|
click(save)
|
|
else: # 不保存直接进行下一步
|
|
second_next_step = Text("下一步")
|
|
if not second_next_step.exists:
|
|
wait_until(second_next_step.exists)
|
|
click(second_next_step)
|
|
confirm = Text("确认")
|
|
if not confirm.exists:
|
|
wait_until(confirm.exists)
|
|
click(confirm)
|
|
# 后退
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
if save_result: # 进入保存页面还需要再后退一步
|
|
back_2 = S('div.back')
|
|
if not back_2.exists:
|
|
wait_until(back_2.exists)
|
|
click(back_2)
|
|
|
|
def pls(self, result=[], multiple=1, is_group=True, save_result=True):
|
|
"""
|
|
"""
|
|
# 点击排列三
|
|
_pls = S('p.lottname.p3')
|
|
wait_until(_pls.exists)
|
|
click(_pls)
|
|
if is_group: # 组选
|
|
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}不存在")
|
|
wait_until(Text("组3").exists)
|
|
click(Text("组3"))
|
|
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"对子号:{double_ball.web_element.text}")
|
|
print(f"非对子号:{single_ball.web_element.text}")
|
|
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("+继续添加"))
|
|
else:
|
|
for index, item in enumerate(result):
|
|
hundred_ball = S(f'//*[@id="body"]/section/div[3]/div[1]/div[2]/ul/li[{int(item[0]) + 1}]/p')
|
|
if hundred_ball.exists:
|
|
click(hundred_ball)
|
|
ten_ball = S(f'//*[@id="body"]/section/div[3]/div[2]/div[2]/ul/li[{int(item[1]) + 1}]/p')
|
|
if ten_ball.exists:
|
|
click(ten_ball)
|
|
single_ball = S(f'//*[@id="body"]/section/div[3]/div[3]/div[2]/ul/li[{int(item[2]) + 1}]/p')
|
|
if single_ball.exists:
|
|
click(single_ball)
|
|
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("+继续添加"))
|
|
print(f"直选, index:{index}, item:{item}")
|
|
if multiple > 0:
|
|
for i in range(multiple - 1):
|
|
click(Text("+"))
|
|
if save_result: # 是否保存
|
|
save = Text("保存")
|
|
if not save.exists:
|
|
wait_until(save.exists)
|
|
click(save)
|
|
else: # 不保存直接进行下一步
|
|
second_next_step = Text("下一步")
|
|
if not second_next_step.exists:
|
|
wait_until(second_next_step.exists)
|
|
click(second_next_step)
|
|
confirm = Text("确认")
|
|
if not confirm.exists:
|
|
wait_until(confirm.exists)
|
|
click(confirm)
|
|
# 后退
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
if save_result: # 进入保存页面还需要再后退一步
|
|
back_2 = S('div.back')
|
|
if not back_2.exists:
|
|
wait_until(back_2.exists)
|
|
click(back_2)
|
|
|
|
|
|
def zuqiu(self):
|
|
# 点击竞彩足球
|
|
_zq = S('p.lottname.zuqiu')
|
|
if not _zq.exists:
|
|
wait_until(_zq.exists)
|
|
click(_zq)
|
|
# 返回主页
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
|
|
def lanqiu(self):
|
|
# 点击竞彩篮球
|
|
_lq = S('p.lottname.lanqiu')
|
|
if not _lq.exists:
|
|
wait_until(_lq.exists)
|
|
click(_lq)
|
|
# 返回主页
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
|
|
def ren9(self):
|
|
# 点击任选9
|
|
_ren9 = S('p.lottname.ren9')
|
|
if not _ren9.exists:
|
|
wait_until(_ren9.exists)
|
|
click(_ren9)
|
|
# 返回主页
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
|
|
def zuqiu14(self):
|
|
# 点击十四场
|
|
_zq14 = S('p.lottname.zuqiu14')
|
|
if not _zq14.exists:
|
|
wait_until(_zq14.exists)
|
|
click(_zq14)
|
|
# 返回主页
|
|
back_1 = S('a.backlink')
|
|
if not back_1.exists:
|
|
wait_until(back_1.exists)
|
|
click(back_1)
|
|
|
|
|
|
with Chrome() as chrome:
|
|
# chrome.balance()
|
|
# 组选
|
|
result = ['058', '157', '238', '139', '278', '359', '089', '179', '138', '057']
|
|
chrome.pls(result = result, multiple=1)
|
|
# 直选
|
|
# result = ['246', '264', '291', '219', '169']
|
|
# chrome.pls(result=result, is_group=False) |