淘宝全自动下单——解放双手

it2025-08-11  10

家里的卫生纸用的特别快,经常性需要买纸,一次买太多又放不下,双十一囤货省的钱不多,反而是占了家里的地方,所以就考虑设计一个脚本,可以完成一键下单,省去繁琐购买步骤。 我喜欢用卫生纸牌子比较固定,在淘宝上选好一家价格质量合适的链接后,考虑这么设计购入流程:(设计流程参考了一些双十一自动下单脚本)

#mermaid-svg-ytZVjLzg3fwz86tx .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-ytZVjLzg3fwz86tx .label text{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .node rect,#mermaid-svg-ytZVjLzg3fwz86tx .node circle,#mermaid-svg-ytZVjLzg3fwz86tx .node ellipse,#mermaid-svg-ytZVjLzg3fwz86tx .node polygon,#mermaid-svg-ytZVjLzg3fwz86tx .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-ytZVjLzg3fwz86tx .node .label{text-align:center;fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .node.clickable{cursor:pointer}#mermaid-svg-ytZVjLzg3fwz86tx .arrowheadPath{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-ytZVjLzg3fwz86tx .flowchart-link{stroke:#333;fill:none}#mermaid-svg-ytZVjLzg3fwz86tx .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-ytZVjLzg3fwz86tx .edgeLabel rect{opacity:0.9}#mermaid-svg-ytZVjLzg3fwz86tx .edgeLabel span{color:#333}#mermaid-svg-ytZVjLzg3fwz86tx .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-ytZVjLzg3fwz86tx .cluster text{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-ytZVjLzg3fwz86tx .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-ytZVjLzg3fwz86tx text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-ytZVjLzg3fwz86tx .actor-line{stroke:grey}#mermaid-svg-ytZVjLzg3fwz86tx .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-ytZVjLzg3fwz86tx .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-ytZVjLzg3fwz86tx #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-ytZVjLzg3fwz86tx .sequenceNumber{fill:#fff}#mermaid-svg-ytZVjLzg3fwz86tx #sequencenumber{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx #crosshead path{fill:#333;stroke:#333}#mermaid-svg-ytZVjLzg3fwz86tx .messageText{fill:#333;stroke:#333}#mermaid-svg-ytZVjLzg3fwz86tx .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-ytZVjLzg3fwz86tx .labelText,#mermaid-svg-ytZVjLzg3fwz86tx .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-ytZVjLzg3fwz86tx .loopText,#mermaid-svg-ytZVjLzg3fwz86tx .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-ytZVjLzg3fwz86tx .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-ytZVjLzg3fwz86tx .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-ytZVjLzg3fwz86tx .noteText,#mermaid-svg-ytZVjLzg3fwz86tx .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-ytZVjLzg3fwz86tx .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-ytZVjLzg3fwz86tx .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-ytZVjLzg3fwz86tx .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-ytZVjLzg3fwz86tx .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .section{stroke:none;opacity:0.2}#mermaid-svg-ytZVjLzg3fwz86tx .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-ytZVjLzg3fwz86tx .section2{fill:#fff400}#mermaid-svg-ytZVjLzg3fwz86tx .section1,#mermaid-svg-ytZVjLzg3fwz86tx .section3{fill:#fff;opacity:0.2}#mermaid-svg-ytZVjLzg3fwz86tx .sectionTitle0{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .sectionTitle1{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .sectionTitle2{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .sectionTitle3{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-ytZVjLzg3fwz86tx .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .grid path{stroke-width:0}#mermaid-svg-ytZVjLzg3fwz86tx .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-ytZVjLzg3fwz86tx .task{stroke-width:2}#mermaid-svg-ytZVjLzg3fwz86tx .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .taskText:not([font-size]){font-size:11px}#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-ytZVjLzg3fwz86tx .task.clickable{cursor:pointer}#mermaid-svg-ytZVjLzg3fwz86tx .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ytZVjLzg3fwz86tx .taskText0,#mermaid-svg-ytZVjLzg3fwz86tx .taskText1,#mermaid-svg-ytZVjLzg3fwz86tx .taskText2,#mermaid-svg-ytZVjLzg3fwz86tx .taskText3{fill:#fff}#mermaid-svg-ytZVjLzg3fwz86tx .task0,#mermaid-svg-ytZVjLzg3fwz86tx .task1,#mermaid-svg-ytZVjLzg3fwz86tx .task2,#mermaid-svg-ytZVjLzg3fwz86tx .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutside0,#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutside2{fill:#000}#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutside1,#mermaid-svg-ytZVjLzg3fwz86tx .taskTextOutside3{fill:#000}#mermaid-svg-ytZVjLzg3fwz86tx .active0,#mermaid-svg-ytZVjLzg3fwz86tx .active1,#mermaid-svg-ytZVjLzg3fwz86tx .active2,#mermaid-svg-ytZVjLzg3fwz86tx .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-ytZVjLzg3fwz86tx .activeText0,#mermaid-svg-ytZVjLzg3fwz86tx .activeText1,#mermaid-svg-ytZVjLzg3fwz86tx .activeText2,#mermaid-svg-ytZVjLzg3fwz86tx .activeText3{fill:#000 !important}#mermaid-svg-ytZVjLzg3fwz86tx .done0,#mermaid-svg-ytZVjLzg3fwz86tx .done1,#mermaid-svg-ytZVjLzg3fwz86tx .done2,#mermaid-svg-ytZVjLzg3fwz86tx .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-ytZVjLzg3fwz86tx .doneText0,#mermaid-svg-ytZVjLzg3fwz86tx .doneText1,#mermaid-svg-ytZVjLzg3fwz86tx .doneText2,#mermaid-svg-ytZVjLzg3fwz86tx .doneText3{fill:#000 !important}#mermaid-svg-ytZVjLzg3fwz86tx .crit0,#mermaid-svg-ytZVjLzg3fwz86tx .crit1,#mermaid-svg-ytZVjLzg3fwz86tx .crit2,#mermaid-svg-ytZVjLzg3fwz86tx .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-ytZVjLzg3fwz86tx .activeCrit0,#mermaid-svg-ytZVjLzg3fwz86tx .activeCrit1,#mermaid-svg-ytZVjLzg3fwz86tx .activeCrit2,#mermaid-svg-ytZVjLzg3fwz86tx .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-ytZVjLzg3fwz86tx .doneCrit0,#mermaid-svg-ytZVjLzg3fwz86tx .doneCrit1,#mermaid-svg-ytZVjLzg3fwz86tx .doneCrit2,#mermaid-svg-ytZVjLzg3fwz86tx .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-ytZVjLzg3fwz86tx .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-ytZVjLzg3fwz86tx .milestoneText{font-style:italic}#mermaid-svg-ytZVjLzg3fwz86tx .doneCritText0,#mermaid-svg-ytZVjLzg3fwz86tx .doneCritText1,#mermaid-svg-ytZVjLzg3fwz86tx .doneCritText2,#mermaid-svg-ytZVjLzg3fwz86tx .doneCritText3{fill:#000 !important}#mermaid-svg-ytZVjLzg3fwz86tx .activeCritText0,#mermaid-svg-ytZVjLzg3fwz86tx .activeCritText1,#mermaid-svg-ytZVjLzg3fwz86tx .activeCritText2,#mermaid-svg-ytZVjLzg3fwz86tx .activeCritText3{fill:#000 !important}#mermaid-svg-ytZVjLzg3fwz86tx .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-ytZVjLzg3fwz86tx g.classGroup text .title{font-weight:bolder}#mermaid-svg-ytZVjLzg3fwz86tx g.clickable{cursor:pointer}#mermaid-svg-ytZVjLzg3fwz86tx g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-ytZVjLzg3fwz86tx g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-ytZVjLzg3fwz86tx .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-ytZVjLzg3fwz86tx .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-ytZVjLzg3fwz86tx .dashed-line{stroke-dasharray:3}#mermaid-svg-ytZVjLzg3fwz86tx #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx .commit-id,#mermaid-svg-ytZVjLzg3fwz86tx .commit-msg,#mermaid-svg-ytZVjLzg3fwz86tx .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-ytZVjLzg3fwz86tx g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-ytZVjLzg3fwz86tx g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-ytZVjLzg3fwz86tx g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-ytZVjLzg3fwz86tx .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-ytZVjLzg3fwz86tx .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-ytZVjLzg3fwz86tx .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-ytZVjLzg3fwz86tx .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-ytZVjLzg3fwz86tx .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-ytZVjLzg3fwz86tx .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-ytZVjLzg3fwz86tx .edgeLabel text{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ytZVjLzg3fwz86tx .node circle.state-start{fill:black;stroke:black}#mermaid-svg-ytZVjLzg3fwz86tx .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-ytZVjLzg3fwz86tx #statediagram-barbEnd{fill:#9370db}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-state .divider{stroke:#9370db}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-ytZVjLzg3fwz86tx .note-edge{stroke-dasharray:5}#mermaid-svg-ytZVjLzg3fwz86tx .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-ytZVjLzg3fwz86tx .error-icon{fill:#522}#mermaid-svg-ytZVjLzg3fwz86tx .error-text{fill:#522;stroke:#522}#mermaid-svg-ytZVjLzg3fwz86tx .edge-thickness-normal{stroke-width:2px}#mermaid-svg-ytZVjLzg3fwz86tx .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-ytZVjLzg3fwz86tx .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-ytZVjLzg3fwz86tx .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-ytZVjLzg3fwz86tx .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-ytZVjLzg3fwz86tx .marker{fill:#333}#mermaid-svg-ytZVjLzg3fwz86tx .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-ytZVjLzg3fwz86tx { color: rgba(0, 0, 0, 0.75); font: ; } 打开淘宝登陆页面 输入账户密码 点击登录 跳转进商品链接 输入数量 点击购买 点击提交订单

整个流程并不复杂,核心就是通过selenium去定位每一步操作用到的元素。 python+selenium安装配置 脚本使用python实现,需要安装python以及selenium,在安装python后,在cmd命令框中直接输入pip install selenium(注意不是在python命令框中)。 安装完成后需要给自己的浏览器添加可以被自动化程序操作的驱动,python对Chrome、IE、Firefox都有较好支持,驱动版本需要根据自己浏览器的版本对应安装,否则会报错。 核心代码

#使用webdriver打开网页 from selenium import webdriver import time browser = webdriver.Chrome() browser.get("https://login.taobao.com") #定位账户输入框,输入账户密码 browser.find_element_by_xpath("//input[@id='fm-login-id']").send_keys("123456789") browser.find_element_by_xpath("//input[@id='fm-login-password']").send_keys("123456789") #点击登录 browser.find_element_by_xpath("//button[@class='fm-button fm-submit password-login']").click() #然后跳转到需要购买的链接页面,点击数量框调整数量,点击立即购买,点击提交订单即可,与前面原理相同

有几个需要注意的问题

如果在定位中使用了中文,要注意自己代码里的编码格式,需要在文件头部加入:# -- coding: utf-8 --,即UTF8编码格式,否则会定位失败,做爬虫时编码同样是一个很重要且闹心的注意事项。在登陆时有可能会被taobao认为是机器人需要进行滑块验证,滑块验证目前自动滑动也是可以被认出来,我这里有了破解方案,可以私信。这里在下单过程没有修改下单地址,使用了默认地址进行下单,因此下单前记得确认一下自己的默认地址是否是自己的收货地址。这个流程中只完成了下单,没有最后支付,主要是为了安全,还是将付款人工完成,可以检查一下下单商品信息、价格、收货地址是否正确,如果有问题还可以修改一次地址或取消订单。 同理,此脚本可以用于购买其他购买流程相同的商品。

完整代码可私聊。

最新回复(0)