python+selenium实现淘宝双十一自动下单

思路/工具参考我的另一篇文章python+selenium实现京东秒杀脚本

1. 扫码登录版

# !/usr/bin/env python
# 2020/05/20
# 淘宝秒杀脚本,扫码登录版
from selenium import webdriver
import datetime,time
driver = webdriver.Chrome(executable_path=r"C:\workspace\Python\chromedriver.exe")
def auto_buy(order_time):print('.........................start.........................')driver.get("https://login.taobao.com/member/login.jhtml")driver.implicitly_wait(10)driver.find_element_by_css_selector('#login > div.corner-icon-view.view-type-qrcode > i').click()time.sleep(10)driver.get("https://cart.taobao.com/cart.htm")if not driver.find_element_by_css_selector('#J_SelectAll1').is_selected():driver.find_element_by_css_selector('#J_SelectAll1').click()while True:now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')if now > order_time:btn=driver.find_element_by_id('J_Go')for i in range(1,20):try:#淘宝每隔一段时间结算按钮点击次数都会不同,可能也是为防止程序操作设置的driver.find_element_by_css_selector('#submitOrderPC_1 > div.wrapper > a.go-btn').click()print('第'+str(i)+'次点击')breakexcept:btn.click()print('.........................抢单成功,尽快付款.........................')time.sleep(10)driver.quit()break
if __name__ if __name__ == "__main__":order_time = input("请输入抢购时间,格式如(2020-05-20 16:45:00.000000):")auto_buy(order_time)print('.........................end.........................')

2 用户名密码登录

使用chrome无头模式速度相对快一点,代码稍有改动,主要是登陆时拖拽验证,代码只需要替换手机号和密码就可用。618/双十一可以试验一下奥。

# !/usr/bin/env python
# coding=utf-8
# 淘宝秒杀脚本,密码登录版
from selenium import webdriver
from selenium.webdriver import  ActionChains
from selenium.webdriver.chrome.options import Options
import datetime,timedef auto_buy(params):print('.........................start.........................')chrome_options = Options()#打开注释就可以开启无头模式#chrome_options.add_argument('--headless')driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r''+params['driverpath'] )driver.get("https://login.taobao.com/member/login.jhtml")driver.implicitly_wait(5)driver.find_element_by_id('fm-login-id').send_keys(params['mobile'])driver.find_element_by_id('fm-login-password').send_keys(params['passward'])time.sleep(1)driver.maximize_window()draggable = driver.find_element_by_id('nc_1_n1z')# #利用js将定位到的元素拖动到可见区域driver.execute_script("arguments[0].scrollIntoView();", draggable)ActionChains(driver).click_and_hold(draggable).perform()# 拖动ActionChains(driver).move_by_offset(xoffset=300, yoffset=0).perform()ActionChains(driver).release().perform()driver.find_element_by_css_selector('#login-form > div.fm-btn > button').click()driver.find_element_by_css_selector('#mc-menu-hd').click()if not driver.find_element_by_css_selector('#J_SelectAll1').is_selected():driver.find_element_by_css_selector('#J_SelectAll1').click()print('....................确认购物车商品,等待下单...........................')while True:now = datetime.datetime.now()if now > datetime.datetime.strptime(params['order_time'],'%Y-%m-%d %H:%M:%S'):btn=driver.find_element_by_id('J_Go')for i in range(1,20):try:#淘宝每隔一段时间结算按钮点击次数都会不同,可能也是为防止程序操作设置的driver.find_element_by_css_selector('#submitOrderPC_1 > div.wrapper > a.go-btn').click()print('第'+str(i)+'次点击')breakexcept:btn.click()driver.quit()input('抢单成功,尽快付款,按任意键退出:')break
if __name__ == "__main__":params={'mobile':'','passward':'','order_time':'','driverpath':''}params['driverpath'] = input("请输入chromedriver.exe绝对路径:")params['mobile'] = input("请输入淘宝手机号:")params['passward'] = input("请输入淘宝账号密码:")params['order_time'] =input("请输入抢购时间,格式如(2020-06-18 00:00:00):")try:auto_buy(params)except:input('抢单失败,确认下输入是否错误,按任意键退出:')print('.........................end.........................')

python+selenium实现淘宝双十一自动下单相关推荐

  1. python自动下单源码_python+selenium实现淘宝双十一自动下单

    python+selenium实现淘宝双十一自动下单 # !/usr/bin/env python # 2020/05/20 # 淘宝秒杀脚本,扫码登录版 from selenium import w ...

  2. 使用python+selenium清空淘宝购物车

    selenium 概述 思路分析 1. 登录淘宝网 2. 输入用户名和密码 3. 访问购物车 4. 提交订单并确认支付 完整代码 概述 每当双十一等购物节到来的时候,我们经常需要熬夜到凌晨来对心仪的商 ...

  3. Python+selenium实现淘宝秒杀

    Python Python版本 3.7.5 Python的设计哲学是"优雅"."明确"."简单".因此,Perl语言中"总是有多种 ...

  4. Python+Selenium模拟淘宝滑块并爬取商品数据

    注:如果侵犯了Alibaba的权益,请联系我删除. 上一篇博客已经完成了模拟淘宝登陆,本节主要记录如何爬取淘宝商品列表页数据,同时如何模拟人的操作完成滑块的验证. 代码如下: #encoding=ut ...

  5. 用selenium实现淘宝毫秒级自动抢券

    淘宝秒杀脚本,扫码登录版 from selenium import webdriver import datetime import time def main():# 打开淘宝登录页,并进行扫码登录 ...

  6. Python selenium模拟淘宝登陆

    通过selenium定位到各个元素,通过相关操作(如输入框的输入,按钮的点击等)来模拟人的真实操作流程 流程是通过绕个圈子,用微博账号登陆来绕过淘宝登陆,不过事先需要将微博账号与淘宝账号进行绑定 下面 ...

  7. python做淘宝_用python做个淘宝双十一满减攻略,再也不用算算算了

    双十一还有不到10天,购物车已经快加满了,但是钱包里就这么多钱,如何用现有的钱买到更多喜欢的东西,成为我比较头疼的事,因为我已经被各种组合加法搞晕了 于是我决定用python做个双十一购物攻略,把复杂 ...

  8. 利用selenium实现淘宝双十一抢购商品

    参考链接https://mp.weixin.qq.com/s/9mX5JoKZjFZlcA0xZn-bqQ 到双十一了总是有一些定时抢购的货物,有了这个脚本再也不用炼手速了. 在这个基础上使用Pyth ...

  9. 淘宝双十一自动刷喵币

    该工具仅限安卓7.0及以上使用,无需Root权限,链接在最后. 使用时一键安装,只需要开启无障碍中的服务权限,本人测试过程中发现小米手机只需第一次开启即可,而华为魅族等手机会自动关闭无障碍,所以可能每 ...

最新文章

  1. android 5.0 ios 8,iOS 8与Android 5.0大比拼:功能相同 体验不同
  2. .net EF监控 MiniProfiler
  3. 正则表达式 语言间通用
  4. 【Flask项目】项目准备之-创建项目的APP对象
  5. Linux系统编程(九)线程同步
  6. mysql fulltext 分页_关于MySQL的FULLTEXT实现全文检索的注意事项
  7. 视觉SLAM十四讲学习笔记-第二讲-开发环境搭建
  8. HTML5促使本地应用向Web迁移
  9. 【DP】LeetCode 53. Maximum Subarray
  10. if...else 应用(猜幸运数字)
  11. 为Google Reader守夜。。。
  12. linux嵌入式面试300问,经典嵌入式Linux面试题3问
  13. 稀疏矩阵的三种存储方法
  14. 恢复桌面计算机图标不见了怎么办,桌面的图标不见了怎么恢复,桌面图标不见了怎么办...
  15. 楚留香冰最新服务器,一梦江湖:各门派冰雪外观极寒之刃上线,冰晶透亮玩家直呼绝了!...
  16. jquery 遍历父元素、子元素、兄弟元素
  17. 偏振光及其在摄影上的应用
  18. Chatbot是什么?chatbot平台有哪些?有什么AI chatbots推荐?SaleSmartly chatbot助力独立站运营
  19. jieba的简单使用
  20. [0520更新]雷达原理【部分]答案 陈伯孝

热门文章

  1. T-test数据分析
  2. Filecoin周报-39期:Filecoin Testnet/3按约定如期上线!
  3. Codeforces Round #791 (Div. 2)(A-D)
  4. 我的软件推广成功之路 [转]
  5. 初学MSP430F5529定时器
  6. html横向自动滚动代码,不间断无缝滚动代码(横向、竖向)
  7. 美国全国就业普遍低迷“技术”就业却加速增长;爱立信发布2030年10大消费者趋势 | 美通社头条...
  8. oracle 11g asm升级,Oracle 11g R1中ASM增强
  9. ABP EF Core多数据库支持
  10. 周志华《机器学习》勘误表