python抢小米6自动化脚本
#!/bin/env python
# coding=utf-8 from selenium import webdriver
import time
import unittest class GetXiaoMi:
driver = webdriver.Chrome()
url = 'https://item.mi.com/product/10000041.html' def login(self):
# try:
self.driver.get(self.url)
home_login_butten = self.driver.find_element_by_xpath(".//*[@id='J_buyBox']/div/div[1]/div/a[1]")
home_login_butten.click()
input_username = self.driver.find_element_by_class_name('item_account')
input_username.clear()
input_username.send_keys('username')
input_password = self.driver.find_element_by_id('pwd')
input_password.clear()
input_password.send_keys('password')
login_butten = self.driver.find_element_by_id('login-button')
login_butten.click()
self.driver.assertIsNotNone(self.driver.find_element_by_xpath(".//*[@id='error-outcon']/div/span]"),
u"登陆失败,请检查用户名或密码")
# except Exception, e:
# print e @staticmethod
def get_sys_time():
sys_time = time.time()
return sys_time @staticmethod
def set_stamp():
set_time = '2017-05-12 09:59:55' # 设置抢购时间,最好提前几秒
# 将其转换为时间数组
time_array = time.strptime(set_time, '%Y-%m-%d %H:%M:%S')
# 转换为时间戳
time_stamp = int(time.mktime(time_array))
return time_stamp def get_xiaomi(self):
try:
if self.get_sys_time() >= self.set_stamp():
while True:
self.driver.find_element_by_class_name('btn btn-primary btn-biglarge J_proBuyBtn add').click()
if self.assertTrue(u'你来晚了', driver.title):
print u'又悲剧了,默默的问候小米~'
break
else:
print u'<-------------赶紧手动付款吧------------>'
else:
print u'时间设置错误'
except Exception, e:
print e if __name__ == '__main__':
run = GetXiaoMi()
run.get_xiaomi()
代码报错?你是否安装了selenium模块?请自行百度~
PS:最后我想说的是,脚本调试中,不一定好用,没有调接口来的痛快,哎,屌丝的人生就是这样的,干什么都得靠抢。
python抢小米6自动化脚本的更多相关文章
- 纯python自研接口自动化脚本更新版本,让小白也能实现0到1万+的接口自动化用例
查看完整文章点击原文链接:纯python自研接口自动化脚本更新版本,让小白也能实现0到1万+的接口自动化用例 你是否还在用postman\jmeter做接口自动化吗?用python的开源框架[unit ...
- Python+selenium第一个自动化脚本
第一个自动化脚本(用Python写的) from selenium import webdriver #从selenium导入webdriber driver=webdriber.Firefox() ...
- Python+Appium自动化测试(3)-编写自动化脚本
之前一篇博客已经讲述怎样手动使用appium-desktop启动测试机上的app,但我们实际跑自动化脚本的过程中,是需要用脚本调用appium启动app的,接下来就尝试写Python脚本启动app并登 ...
- python dvwa布尔盲注自动化脚本(level=low)
仅供学习代码参考 1#python dvwa布尔盲注自动化脚本 2 import requests 3 import string 4 import time 5 INIT_URL="htt ...
- python抢火车票的脚本
起因: 想着那么多人,抢不到火车票.感觉到一丝感慨 所以有了抢火车票这个脚本. 0x01 思路:自动打开浏览器,自动输入账号密码 知道查看.自动预定. 0x02 要用到的模块 splinter模块: ...
- bat文件一键运行python自动化脚本
目标:建立一个双击即可运行自动化脚本的机制,而不用每次运行编译器,方便测试人员用户体验. 方法: 1. 将所有代码打包成exe文件,但一旦修改,又要重新打包. 2. 将运行代码写成bat文件,双击即执 ...
- selenium+python自动化105 - selenium 如何在已打开的浏览器上继续运行自动化脚本?
前言 使用selenium 做web自动化的时候,经常会遇到这样一种需求,是否可以在已经打开的浏览器基础上继续运行自动化脚本? 这样前面的验证码登录可以手工点过去,后面页面使用脚本继续执行,这样可以解 ...
- 抢小米软件html版(简单有效)
地球人都知道小米性价比高,大家都很期待,但是抢小米却是一件很头疼的事. 本来抢的人就多,还有一些大牛.黄牛使用软件来抢,人家有成百上千台电脑,开上几万个线程,很难抢过人家... 小菜分享一款简单的小米 ...
- appium-desktop录制脚本二次开发,生成我司自动化脚本
目的 通过对appium-desktop脚本录制功能进行二次开发,使录制的java脚本符合我司自动化框架要求. 实现步骤 1.增加元素名称的输入框 由于ATK(我司自动化测试框架)脚本中元素是以“ap ...
随机推荐
- hihoCoder #1082 : 然而沼跃鱼早就看穿了一切(字符串处理)
#1082 : 然而沼跃鱼早就看穿了一切 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句 ...
- Codeforces 810C Do you want a date?(数学,前缀和)
C. Do you want a date? time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- 2017ecjtu-summer training #1 UVA 10399
It has been said that a watch that is stopped keeps better time than one that loses 1 second per day ...
- Java集合系列[4]----LinkedHashMap源码分析
这篇文章我们开始分析LinkedHashMap的源码,LinkedHashMap继承了HashMap,也就是说LinkedHashMap是在HashMap的基础上扩展而来的,因此在看LinkedHas ...
- 使用setTimeout实现setInterval
setInterval = () =>{ console.log(1) //使用递归 setTimeout(setInterval,1000); }; setInterval()
- 使用gitbook 发布一个教程文档网站
gitbook是一个好用的发布电子书的项目:使用gitbook 可以在本地写好文档再远程推送到库:也可以在gitbook提供的在线平台上制作电子书:要想在自己的服务器上使用gitbook 发布一个网站 ...
- 将项目(代码)从GitHub上克隆(下载)到本地仓库
要将项目从GitHub上克隆到本地,首先你得下载并安装好git for window. 下载地址:http://www.xp510.com/xiazai/Application/other/30988 ...
- 现代 PHP 新特性系列(三) —— Trait 概览
Trait是PHP 5.4引入的新概念,看上去既像类又像接口,其实都不是,Trait可以看做类的部分实现,可以混入一个或多个现有的PHP类中,其作用有两个:表明类可以做什么:提供模块化实现.Trait ...
- 什么是redis,redis能做什么,redis应用场景
Redis是一个key-value存储系统.Redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部分场合可以对关系数据库起到很好的补充作用.这篇文章小编为大家分享了在 ...
- robots书写说明:
"User-Agent"搜索引擎的名字. 针对所有搜索引擎写法:User-Agent: *,针对百度搜索引擎写法:User-Agent:Baiduspider "Allo ...