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_1028_母函数
虽然我很想自己写母函数讲解...但是最近事情太多了,就贴个很入门的讲解吧给出一个经典的模板A了这个题 http://blog.csdn.net/vsooda/article/details/79754 ...
- Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool
A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input s ...
- Flexbox 练习和总结
练习地址: http://flexboxfroggy.com/ Welcome to Flexbox Froggy, a game where you help Froggy and friends ...
- c语言基础学习08_内存管理
=============================================================================涉及到的知识点有:一.内存管理.作用域.自动变 ...
- Eclipse安装svn插件的几种方式 转帖....
Eclipse安装svn插件的几种方式 1.在线安装: (1).点击 Help --> Install New Software... (2).在弹出的窗口中点击add按钮,输入Name(任意) ...
- 基础二 day4 日记
1.list增删改查 l1 = [1,'alex',True,[1,2,3],(2,3,4),{'name':'alex'}]l1 = ['alex',True,'wusir','ritian','t ...
- ZooKeeper 分布式共享锁的实现
原创播客,如需转载请注明出处.原文地址:http://www.cnblogs.com/crawl/p/8352919.html ------------------------------------ ...
- JSP内置对象1(request,response,session)
request对象 response对象:请求重定向与请求转发的区别. session对象:表示客户端与服务器的一次会话,也就是用户浏览网站所花费的时间.在服务器的内存中保存着不同用户的session ...
- 网站搭建中,怎么区分ASP和PHP
1:空间支持上 ASP:程序要求比较低,空间只要支持ASP+access即可运行 PHP:配置要求比较高,空间需要支持PHP及数据库,而且程序和数据库是单独的,一般的 unix空间都是这种配置. 2: ...
- dede织梦怎么修改description的字数
织梦在调用描述的时候都会使用description来调用描述,想要更改字数也可以控制调用的字数,但是就算是这样更改也是有字数限制的,描述的字数是不能没有限制. 在模板中调用描述的标签一般有四种: 1: ...