下单优化 version update 1.2.004

pull/518/head^2
xianping.wen 5 years ago
parent 04a2716b8e
commit 0cfefe239d

@ -9,19 +9,19 @@ TICKET_TYPE = 1
# 出发日期(list) "2018-01-06", "2018-01-07"
STATION_DATES = [
"2020-01-17"
"2020-01-18"
]
# 填入需要购买的车次(list)"G1353"
# 修改车次填入规则,注:(以前设置的车次逻辑不变),如果车次填入为空,那么就是当日乘车所有车次都纳入筛选返回
# 不填车次是整个list为空才算如果不是为空依然会判断车次的这种是错误的写法 [""], 正确的写法 []
STATION_TRAINS = ["G1120"]
STATION_TRAINS = []
# 出发城市,比如深圳北,就填深圳就搜得到
FROM_STATION = "广州"
FROM_STATION = "广州"
# 到达城市 比如深圳北,就填深圳就搜得到
TO_STATION = "武汉"
TO_STATION = "隆回"
# 座位(list) 多个座位ex:
# "商务座",
@ -42,7 +42,7 @@ IS_MORE_TICKET = True
# 乘车人(list) 多个乘车人ex:
# "张三",
# "李四"
TICKET_PEOPLES = [""]
TICKET_PEOPLES = []
# 12306登录账号
USER = ""
@ -113,7 +113,7 @@ ORDER_MODEL = 1
IS_PROXY = 0
# 预售放票时间, 如果是捡漏模式,可以忽略此操作
OPEN_TIME = "12:59:50"
OPEN_TIME = "12:59:57"
# 1=使用selenium获取devicesID
# 2=使用网页端/otn/HttpZF/logdevice获取devicesId这个接口的算法目前可能有点问题如果登录一直302的请改为配置1
# 3=自己打开浏览器在headers-Cookies中抓取RAIL_DEVICEID和RAIL_EXPIRATION这个就不用配置selenium
@ -126,8 +126,10 @@ CHROME_PATH = "/usr/src/app/chromedriver"
CHROME_CHROME_PATH = "/opt/google/chrome/google-chrome"
# 如果COOKIE_TYPE=3, 则需配置RAIL_EXPIRATION、RAIL_DEVICEID的值
RAIL_EXPIRATION = "1577033439142"
RAIL_DEVICEID = "PuV16sVaV-CTGsFZUuL8JLAk4OhuT1wgUYC_W3L2JZfWx8Ygx8LOPkko3PSOrK5_xSKhXjgyTMS8dBmj1RZHL2CKBTmVs6UG_yptlB4NJbGHldltrLMTUEgoDpSkpX2vzpGXgMQsTRzgOXfuQkAWwS4GjCxSmV3C; BIGipServerpassport=820510986.50215.0000; route=9036359bb8a8a461c164a04f8f50b252"
RAIL_EXPIRATION = ""
RAIL_DEVICEID = ""
# RAIL_EXPIRATION = "1577034103293"
# RAIL_DEVICEID = "CDno29Erc_Pf3FSXb4dzq-Op64EhWrsi5yUZKVIKR1MAfYo2qFlCeXD8VkexY7_1qg-ClV-fE8j9jgVlPZxRh3wVc2iqLe_5A8sdr62qZx4B22JPF8lFCjpgTKZ5ODW90HJd5tiQsJ1KR9nOqHRxHj1FT5LEIwfw"
# 1=>为一直随机ua,2->只启动的时候随机一次ua
@ -152,4 +154,4 @@ MAX_TIME = 3
MIN_TIME = 1
# 软件版本
RE_VERSION = "1.2.003"
RE_VERSION = "1.2.004"

@ -38,7 +38,7 @@ class select:
self.get_ticket_info()
self._station_seat = [seat_conf[x] for x in TickerConfig.SET_TYPE]
self.auto_code_type = TickerConfig.AUTO_CODE_TYPE
self.httpClint = HTTPClient(TickerConfig.IS_PROXY)
self.httpClint = HTTPClient(TickerConfig.IS_PROXY, self.cdn_list)
self.httpClint.cdn = self.cdn_list[random.randint(0, 4)]
self.urls = urlConf.urls
self.login = GoLogin(self, TickerConfig.IS_AUTO_CODE, self.auto_code_type)

@ -24,24 +24,27 @@ def _set_header_default():
def _set_user_agent():
try:
user_agent = UserAgent(verify_ssl=False).random
return user_agent
except:
print("请求头设置失败,使用默认请求头")
return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.' + str(
random.randint(5000, 7000)) + '.0 Safari/537.36'
# try:
# user_agent = UserAgent(verify_ssl=False).random
# return user_agent
# except:
# print("请求头设置失败,使用默认请求头")
# return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.' + str(
# random.randint(5000, 7000)) + '.0 Safari/537.36'
return "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
class HTTPClient(object):
def __init__(self, is_proxy):
def __init__(self, is_proxy, cdnList=None):
"""
cdnList试试切换不包括查询的cdn防止查询cdn污染登陆和下单cdn
:param method:
:param headers: Must be a dict. Such as headers={'Content_Type':'text/html'}
"""
self.initS()
self._cdn = None
self.cdnList = cdnList
self._proxies = None
if is_proxy is 1:
self.proxy = proxy()
@ -185,8 +188,12 @@ class HTTPClient(object):
bytes) else response.content
else:
print(f"url: {urls['req_url']}返回参数为空, 接口状态码: {response.status_code}")
logger.log(
u"url: {} 返回参数为空".format(urls["req_url"]))
if self.cdnList:
# 如果下单或者登陆出现cdn 302的情况立马切换cdn
url_host = self.cdnList.pop(random.randint(0, 4))
continue
else:
sleep(urls["re_time"])

Loading…
Cancel
Save