前言
拒绝黄牛,从你我做起,这里为大家分享一下最近我所编写的抢票脚本,可实现web+app端抢票。
环境:
python3.8
chromedriver:21
android-sdk:33
直接上代码
安装依赖
首先,安装必要的Python库:
pip install selenium
下载并安装ChromeDriver,确保其版本与本地安装的Chrome浏览器版本匹配。将ChromeDriver的路径添加到系统的环境变量中,或者在脚本中指定路径。
网页版抢票脚本
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
def setup_driver():
# ChromeDriver路径
service = Service(‘path/to/chromedriver’)
options = webdriver.ChromeOptions()
options.add_argument(‘–start-maximized’)
driver = webdriver.Chrome(service=serv