118

用Python自动刷新抢12306火车票(附源码)

 6 years ago
source link: http://developer.51cto.com/art/201801/562501.htm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

用Python自动刷新抢12306火车票(附源码)

作者:marvin 2018-01-02 09:56:04
一年一度的春运又来了,今年我自己写了个抢票脚本。使用Python+Splinter自动刷新抢票,可以成功抢到。(依赖自己的网络环境太厉害,还有机器的好坏)

 

d1bd47c64ec28f6f514718520e84b4a3.jpeg

一年一度的春运又来了,今年我自己写了个抢票脚本。使用Python+Splinter自动刷新抢票,可以成功抢到。(依赖自己的网络环境太厉害,还有机器的好坏)

Splinter是一个使用Python开发的开源Web应用测试工具,它可以帮你实现自动浏览站点和与其进行交互,Splinter执行的时候会自动打开你指定的浏览器,访问指定的URL。然后你所开发的模拟的任何行为,都会自动完成,你只需要坐在电脑面前,像看电影一样看着屏幕上各种动作自动完成然后收集结果即可。

12306抢票Python代码片段

1、实现自动登录的函数:

6b0b99ffd6678b3636d2bdc11c30675c.png

2、开始购票的函数

6b0b99ffd6678b3636d2bdc11c30675c.png
责任编辑:庞桂玉 来源: Python中文社区

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK