|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
有抢去珠海车票的需要,在Github 上看到有人分享了一段这样的代码。
但我看不懂究竟代码中#command need to be replaced, see readme 。这一句中command 到底需要
变更为什么?
有没有哪位大神能告诉我这段代码究竟要怎么改?
原文在此:
https://github.com/haoranliu666/BuyTicket_ZhuHaiHongKong
README.md
BuyTicket_ZhuHaiHongKong
https://i.hzmbus.com/webhtml/ticket_details?xlmc_1=香港&xlmc_2=珠海&xllb=1&xldm=HKGZHO&code_1=HKG&code_2=ZHO
Open the url in Chrome;
Press F12;
Select Network;
Select All;
Select the date of ticket you wanna buy;
Right click 'query.book.info.data';
Select Copy;
Select Copy as cURL;
Transfer the data into python readable type, and name it as 'content';
Run the python file.
import subprocess
import json
import os
import time
#command need to be replaced, see readme
command = ''
while 1==1:
return_data = subprocess.check_output(command, shell=True)
return_data_utf8 = return_data.decode('UTF-8')
dict_data = json.loads(return_data_utf8)
response_data = dict_data['responseData']
for bus in response_data:
if bus['totalPeople'] != bus['maxPeople'] and bus['saleStatus'] == 1:
print('*********ticket!!!**********')
print(bus)
print('*********ticket!!!**********')
for i in range(0, 100):
os.system('say "ticket"')
count += 1
print(count)
print(response_data)
time.sleep(60)
|
|