You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
import random |
|
from urllib.parse import urljoin |
|
from config import global_data |
|
from lib.http_req import req |
|
from lib.redis_util import redis_get_key |
|
|
|
SUB_URL = '?m=web&a=getAllSeats' |
|
|
|
|
|
class GetAllSeats: |
|
def __init__(self, data): |
|
self.api_name = 'get_all_seats' |
|
self.url = urljoin(data['basic_data']['url_http'], SUB_URL) |
|
self.user_name = data['basic_data']['user_name'] # 固定写死的参数 |
|
self.password = data['basic_data']['password'] # 固定写死的参数 |
|
self.cinema_id = data['basic_data']['cinema_id'] |
|
self.req_method = data['http_req_method'] # http接口请求方法POST或GET |
|
self.show_day = None |
|
|
|
def prepare(self): |
|
show_days_list = redis_get_key('json_get_show_days')['data'] # 获取getShowDays返回值 |
|
self.show_day = random.choice(show_days_list) # 随机获取日期 |
|
|
|
def request(self): |
|
# 准备请求数据 |
|
self.prepare() |
|
|
|
params = { |
|
'user': self.user_name, # 授权用户名 |
|
'pass': self.password, # 授权密码 |
|
'cinema': self.cinema_id, # 影院三位编码 |
|
} |
|
data = { |
|
'showDate': self.show_day, # 放映日期 |
|
} |
|
|
|
resp_params, resp_data, response = req(self.api_name, self.url, self.req_method, params, data) |
|
|
|
# 处理返回的数据 |
|
self.handle() |
|
|
|
return resp_params, resp_data, response |
|
|
|
def handle(self): |
|
pass |
|
|
|
|
|
if __name__ == "__main__": |
|
api = GetAllSeats(global_data) |
|
api.request()
|
|
|