主要功能:
填写抢购时间点击抢购购物车抢购购物车捡漏模式商品页面强制开启抢购模式正常商品页面抢购正常非抢购商品页面auto.waitFor();
var height = device.height;
var width = device.width;
toast("开启")
setScreenMetrics(width, height);
start();
function start()
{
gotoMiaoBi();
miaoBiCenter();
toast("finished")
}
function gotoMiaoBi()
{
if(className("android.widget.Button").text("").exists()){
className("android.widget.Button").text("").click();
toast("")
sleep(4000);
}
}
function miaoBiCenter()
{
var count = 3;
while(count-- > 0)
{
browseJobs("");
browseJobs("");
browseJobs("");
doFinishJob();
getRewards();
sleep(3000);
}
}
function getRewards()
{
while(text("").exists())
{
text("").findOne().click();
sleep(2000);
}
}
function browseJobs(target)
{
while(text(target).exists())
{
text(target).findOne().click();
sleep(3000)
var count = 0;
while(count ++ < 7)
{
swipe(width / 2, height/2, width / 2, height/10, 500);
sleep(3000);
}
back();
sleep(3000)
}
}
function doFinishJob()
{
if(text("").exists())
{
var finishedList = text("").find();
for(let i=0;i<finishedList.size();i++)
{
var finished = finishedList.get(i);
var title = finished.parent().child(0).child(0).text();
if(title.indexOf("") != -1 || title.indexOf("") != -1)
{
toast(title);
sleep(2000);
}else {
finished.click();
sleep(3000);
var count = 0;
while(count ++ < 7)
{
swipe(width / 2, height/2, width / 2, height/10, 500);
sleep(3000);
}
back();
sleep(3000)
}
}
}
}
driver.get(‘https://www.tianmao.com/’)
class pay: # 登录模块 def login_in(self, num, pwd, times)
: # 点击登入 driver.find_element_by_class_name(‘h’).click() time.sleep(0.3) # 发送账号密码 driver.find_element_by_id(‘fm-login-id’).send_keys(num) driver.find_element_by_id(‘fm-login-password’).send_keys(pwd) time.sleep(0.2) # 点击登入 driver.find_element_by_class_name(‘fm-btn’).click() time.sleep(1) # 进入购物车 driver.get(“https://cart.taobao.com/cart.htm”) # driver.find_element_by_id(‘mc-menu-hd’).click() # time.sleep(0.2) driver.find_element_by_id(‘J_SelectAll1’).click() time.sleep(0.5) self.auto_check1(times)
#反复结算
def auto_check(self,times):
while True:
try:
if driver.find_element_by_id('J_SelectAll1'):
driver.find_element_by_id('J_SelectAll1').click()
time.sleep(0.5)
break
except:
time.sleep(0.5)
pass
while True:
if datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') >= times:
while True:
try:
driver.find_element_by_id("J_Go").click()
print("成功结算")
driver.find_element_by_link_text('提交订单').click()
print(f"抢购成功,请尽快付款")
time.sleep(5)
return 0
except:
print("无法结算,重试")
time.sleep(1)
driver.get("https://cart.taobao.com/cart.htm")
self.auto_check(times)
def auto_check1(self,times):
while True:
if datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') >= times:
while True:
try:
driver.find_element_by_id("J_Go").click()
print("成功结算")
driver.find_element_by_link_text('提交订单').click()
print(f"抢购成功,请尽快付款")
time.sleep(5)
return 0
except:
print("无法结算,重试")
time.sleep(1)
driver.get("https://cart.taobao.com/cart.htm")
self.auto_check(times)
# 运行
def run_driver(self, num, pwd, times):
self.login_in(num, pwd, times)
如有不理解的地方,可以留言,我会一一解答。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)