Python 脚本实现淘宝准点秒杀功能
下载地址:https://download.csdn.net/download/tangcv/11968538
pycharm文件太大,不好上传,直接去官网下载:https://www.jetbrains.com/pycharm/download/#section=windows
配置环境
1.安装python
双击
然后跟着感觉走,
创建一个专门的文件夹用来放python环境
安装好
2..安装pycharm
1、首先去Pycharm官网,或者直接输入网址:http://www.jetbrains.com/pycharm/download/#section=windows,下载PyCharm安装包,根据自己电脑的操作系统进行选择,对于windows系统选择下图的框框所包含的安装包。
破解涉嫌版权问题,请自行解决
3.安装火狐浏览器、火狐浏览器安装FireBug插件火狐浏览器
双击Firefox-latest安装火狐浏览器
FireBug插件
右上角附加组件>扩展>搜索FireBug
选择Omnibug安装
按F12出现下图,安装成功
4.geckodriver驱动安装
1.解压geckodriver-v0.26.0-win64
2.将geckodriver放到该浏览器可执行文件的路径下
3.添加到环境变量中
测试配置是否完成用pycharm创建一个python项目
File>Settings>project:ms>projectinterpreter添加selectninm和urlib3
新建一个python文件
#-*-coding:utf-8-*- fromseleniumimportwebdriver driver=webdriver.Firefox()
右键执行
浏览器自动打开进入百度
完成配置
淘宝秒杀程序二维码登录
#!/usr/bin/envpython
#-*-coding:utf-8-*-
#2018/09/05
#淘宝秒杀脚本,扫码登录版
importos
fromseleniumimportwebdriver
importdatetime
importtime
fromosimportpath
fromselenium.webdriver.common.action_chainsimportActionChains
d=path.dirname(__file__)
abspath=path.abspath(d)
driver=webdriver.Firefox()
driver.maximize_window()
deflogin():
#打开淘宝登录页,并进行扫码登录
driver.get("https://www.taobao.com")
time.sleep(3)
ifdriver.find_element_by_link_text("亲,请登录"):
driver.find_element_by_link_text("亲,请登录").click()
print("请在30秒内完成扫码")
time.sleep(30)
driver.get("https://cart.taobao.com/cart.htm")
time.sleep(3)
#点击购物车里全选按钮
#ifdriver.find_element_by_id("J_CheckBox_939775250537"):
#driver.find_element_by_id("J_CheckBox_939775250537").click()
#ifdriver.find_element_by_id("J_CheckBox_939558169627"):
#driver.find_element_by_id("J_CheckBox_939558169627").click()
ifdriver.find_element_by_id("J_SelectAll1"):
driver.find_element_by_id("J_SelectAll1").click()
now=datetime.datetime.now()
print('loginsuccess:',now.strftime('%Y-%m-%d%H:%M:%S:%f'))
defbuy(buytime):
whileTrue:
now=datetime.datetime.now().strftime('%Y-%m-%d%H:%M:%S.%f')
print("当前时间"+now)
#对比时间,时间到的话就点击结算
ifnow>buytime:
try:
#点击结算按钮
ifdriver.find_element_by_id("J_Go"):
driver.find_element_by_id("J_Go").click()
driver.find_element_by_link_text('提交订单').click()
except:
time.sleep(0.1)
print(now)
time.sleep(0.1)
if__name__=="__main__":
#times=input("请输入抢购时间:")
#时间格式:"2018-09-0611:20:00.000000"
login()
buy("2019-11-1001:14:00.000000")
账号密码登录
#!/usr/bin/envpython
#-*-coding:utf-8-*-
#2018/09/05
#淘宝秒杀脚本,扫码登录版
importos
fromseleniumimportwebdriver
importdatetime
importtime
fromosimportpath
fromselenium.webdriver.common.action_chainsimportActionChains
d=path.dirname(__file__)
abspath=path.abspath(d)
driver=webdriver.Firefox()
driver.maximize_window()
deflogin(uname,pwd):
driver.get("https://www.taobao.com")
ifdriver.find_element_by_link_text("亲,请登录"):
driver.find_element_by_link_text("亲,请登录").click()
input(uname,pwd)
#点击购物车里全选按钮
ifdriver.find_element_by_id("J_SelectAll1"):
driver.find_element_by_id("J_SelectAll1").click()
#time.sleep(3)
now=datetime.datetime.now()
print('loginsuccess:',now.strftime('%Y-%m-%d%H:%M:%S'))
definput(uname,pwd):
time.sleep(3)
#选择密码登录
ifdriver.find_element_by_id("J_Quick2Static"):
driver.find_element_by_id("J_Quick2Static").click()
time.sleep(3)
#用户名输入
ifdriver.find_element_by_name("TPL_username"):
foriinuname:
driver.find_element_by_name("TPL_username").send_keys(i)
time.sleep(0.5)
time.sleep(3)
#密码输入
ifdriver.find_element_by_name("TPL_password"):
forjinpwd:
driver.find_element_by_name("TPL_password").send_keys(j)
time.sleep(0.5)
time.sleep(3)
#点击登录按钮
ifdriver.find_element_by_id("J_SubmitStatic"):
driver.find_element_by_id("J_SubmitStatic").click()
time.sleep(3)
driver.get("https://cart.taobao.com/cart.htm")
time.sleep(2)
defbuy(buytime):
whileTrue:
now=datetime.datetime.now().strftime('%Y-%m-%d%H:%M:%S')
ifnow==buytime:
try:
#点击结算按钮
ifdriver.find_element_by_id("J_Go"):
driver.find_element_by_id("J_Go").click()
driver.find_element_by_link_text('提交订单').click()
except:
time.sleep(1)
print(now)
time.sleep(1)
if__name__=="__main__":
#中文账号记得decode编码
login("账号",'密码')
buy('2019-11-1001:01:01.000001')
总结
以上所述是小编给大家介绍的Python脚本实现淘宝准点秒杀功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。