GitHub项目推荐:Automatic_ticket_purchase

大麦网抢票脚本

MakiNaruto/Automatic_ticket_purchase

开发语言: Python

地址: https://github.com/MakiNaruto/Automatic_ticket_purchase

推荐理由:之前的脚本通过按钮操作,需要等待浏览器加载,效率低下。作者在这基础上进行了升级,首先通过 selenium 打开页面进行登录,其余操作均通过 requests 进行请求进行操作,极大地提高了抢票的效率。

目前支持的功能:
增加选座购买,暂时只支持抢购指定价格下的座位

不支持的功能:
暂不支持连座位购买
不支持选座

所以,如果购买时,需要选座位的话,需要慎重考虑是否要使用了。

程序执行流程如下
GitHub 项目推荐:Automatic_ticket_purchase

使用准备工作

1. 配置环境

1.1 安装所需要的环境


pip install -r requirements.txt

具体的依赖如下:


beautifulsoup4==4.9.3
requests==2.24.0
selenium==3.141.0
pyexecjs==1.5.1

1.2 需要下载与系统安装对应的 ChromeDriver 驱动并配置(也可以改用其他浏览器驱动),

下载地址: http://chromedriver.storage.googleapis.com/index.html

1.3 配置驱动路径,默认在项目根目录下。

例如:windows 系统下,则重命名下载的 chromedriver,将其重命名为 chromedriver_windows


def account_login():
if platform.system().lower() == 'linux':
chromedriver = os.path.join(os.getcwd(), 'chromedriver_linux')
elif platform.system().lower() == 'windows':
chromedriver = os.path.join(os.getcwd(), 'chromedriver_windows')
else:
chromedriver = os.path.join(os.getcwd(), 'chromedriver_mac')

2. 运行

2.1 若采取账号方式,修改代码中下面的信息,进行抢票。

item_id 根据地区来确定,每一个城市对应不同的 item_id。选择相应地区后将箭头指向的 item_id 填写到函数内。


def __init__(self):
...
# 若选择账号登录方式,则需要填写
self.login_id: str = 'account' # 大麦网登录账户名
self.login_password: str = 'password' # 大麦网登录密码
# 以下为抢票必须的参数
self.item_id: int = 610820299671 # 商品 id
self.viewer: list = ['viewer1'] # 在大麦网已填写的观影人
self.buy_nums: int = 1 # 购买影票数量, 需与观影人数量一致
self.ticket_price: int = 180 # 购买指定票价

2.2 运行

初次登陆没有 cookies,默认登录方式为账号密码登录方式,可改成其他方式进行登录,如扫码或短信登录。


# 默认登录方式
python Automatic_ticket_purchase.py
# 指定其他方式登录
python Automatic_ticket_purchase.py --mode qr

© 版权声明

☆ END ☆
喜欢就点个赞吧
点赞0 分享
图片正在生成中,请稍后...