更多精彩内容, 欢迎关注公众号:数量技术宅,也可添加技术宅 个人微信号:sljsz01,与我交流。
总是抢不到想要的宝贝?试试Python脚本
对于淘宝、天猫,相信大家已经无比的熟悉,在每年的双十一、双十二,或是其他购物节,平台都会上架性价比超高的一些商品,商品的性价比越高,自然吸引购买者的眼光也越多。不知道你是否有这样的经历,半夜卡着点等待心仪商品放出,狂点手机,却一秒库存不足。这是因为,背后有许许多多的抢购机器人,在与你竞争,在程序面前,眼睛看到+手工点击的速度,无疑是慢了。
[En]
For Taobao, Tmall, I believe we are already incomparably familiar, in the annual Singles Day, double Twelve, or other shopping festivals, the platform will be on the shelves of some goods with high performance-to-price ratio, the higher the performance-to-price ratio of the goods, the more eyes they naturally attract buyers. Do not know if you have such an experience, stuck in the middle of the night waiting for the favorite goods to be released, crazy point mobile phone, but a second out of stock. This is because, behind there are a lot of rush to buy robots, in competition with you, in front of the program, eyes see + manual click speed, is undoubtedly slow.
本次的文章,技术宅将分享一个淘宝/天猫的秒杀脚本,这个脚本用Python编写,使用到了Python的三方库selenium,并且通过selenium + chromedriver,用程序控制chrome浏览器,完成抢购的一系列操作。有了这个脚本,大家至少可以与其他的机器人站在同一起跑线上,公平的抢购喜欢的宝贝。
selenium 安装与 chromedriver安装
我们前文提到,Python脚本中使用了selenium库,而selenium又通过chromedriver来控制浏览器的鼠标点击等操作。所以,我们的第一步,是正确的安装与配置selenium以及chromedriver。
selenium的安装很简单,与其他Python三方库一样,我们直接用pip安装。
pip install selenium