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 ...
随机推荐
- hdu_2670Girl Love Value(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2670 Girl Love Value Time Limit: 2000/1000 MS (Java/O ...
- 线段树入门HDU_1754
题目链接:点击打开链接 I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Palindromes
http://acm.hdu.edu.cn/showproblem.php?pid=1318 Palindromes Time Limit: 2000/1000 MS (Java/Others) ...
- c与c++d的typedef
一.基本概念剖析 int* (*a[5])(int, char*); //#1 void (*b[10]) (void (*)()); //#2 double(*)() (*pa)[9]; ...
- eclipse(Version: Mars.2 Release (4.5.2)) groovy plugin install process.
There are two way to install : First: 1.check your eclipse version:Help-->About Eclipse 2.open He ...
- C#的LINQ
在过去如果我们如果需要去查询某些集合或者数组里面的某些元素,我们需要写出大量的带有筛选的遍历集合的代码,但是有了Linq之后,我们就不用写出那些冗余麻烦的遍历代码,只需要关注其中的筛选,排列的函数就可 ...
- webpack + babel
webpack设计思想:不区分.png .css .js 等文件,都视为一个模块.通过require导入,loader加载器编译之后打包在一个主js文件里. 优势:减少http请求. 1. webpa ...
- 利用jQuery移除和添加图片
1.样式 <style type="text/css"> .changeImage{ background:url(images/right. ...
- 人人都是CEO
在这个互联网崛起的时代有些流行说法,比如:人人都是产品经理,人人都是程序员以突显行业繁荣的特点,但从更基本的出发点,难道人人不都是 CEO 么?个人的 CEO. 从这个名字套路出发,我沿着想了下去,作 ...
- phpwind9.0升级到php7后出现的问题修复
最近将一个两年多以前的用phpwind9.0搭建的论坛升级到php7,遇到了页面无法打开,显示为500错误,排查了一整天时间,终于解决! 1.打开文件:src/applications/appcent ...