增加使用浏览器缓存RAIL_EXPIRATION 和 RAIL_DEVICEID 配置,解决临时无法登录问题
This commit is contained in:
@@ -109,6 +109,11 @@ WEB_PORT = 8008 # 监听端口
|
|||||||
CDN_ENABLED = 0
|
CDN_ENABLED = 0
|
||||||
CDN_CHECK_TIME_OUT = 1 # 检测单个 cdn 是否可用超时时间
|
CDN_CHECK_TIME_OUT = 1 # 检测单个 cdn 是否可用超时时间
|
||||||
|
|
||||||
|
# 是否使用浏览器缓存中的RAIL_EXPIRATION 和 RAIL_DEVICEID
|
||||||
|
CACHE_RAIL_ID_ENABLED = 0
|
||||||
|
RAIL_EXPIRATION = '' #浏览12306 网站中的Cache的RAIL_EXPIRATION 值
|
||||||
|
RAIL_DEVICEID = '' #浏览12306 网站中的Cache的RAIL_DEVICEID 值
|
||||||
|
|
||||||
# 查询任务
|
# 查询任务
|
||||||
QUERY_JOBS = [
|
QUERY_JOBS = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -94,6 +94,10 @@ class Config:
|
|||||||
CDN_ITEM_FILE = PROJECT_DIR + 'data/cdn.txt'
|
CDN_ITEM_FILE = PROJECT_DIR + 'data/cdn.txt'
|
||||||
CDN_ENABLED_AVAILABLE_ITEM_FILE = QUERY_DATA_DIR + 'available.json'
|
CDN_ENABLED_AVAILABLE_ITEM_FILE = QUERY_DATA_DIR + 'available.json'
|
||||||
|
|
||||||
|
CACHE_RAIL_ID_ENABLED = 0
|
||||||
|
RAIL_EXPIRATION = ''
|
||||||
|
RAIL_DEVICEID = ''
|
||||||
|
|
||||||
# Default time out
|
# Default time out
|
||||||
TIME_OUT_OF_REQUEST = 5
|
TIME_OUT_OF_REQUEST = 5
|
||||||
|
|
||||||
@@ -213,6 +217,10 @@ class Config:
|
|||||||
def is_cdn_enabled():
|
def is_cdn_enabled():
|
||||||
return Config().CDN_ENABLED
|
return Config().CDN_ENABLED
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_cache_rail_id_enabled():
|
||||||
|
return Config().CACHE_RAIL_ID_ENABLED
|
||||||
|
|
||||||
|
|
||||||
class EnvLoader:
|
class EnvLoader:
|
||||||
envs = []
|
envs = []
|
||||||
|
|||||||
@@ -197,10 +197,16 @@ class UserJob:
|
|||||||
if response.text.find('callbackFunction') >= 0:
|
if response.text.find('callbackFunction') >= 0:
|
||||||
result = response.text[18:-2]
|
result = response.text[18:-2]
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
self.session.cookies.update({
|
if not Config().is_cache_rail_id_enabled():
|
||||||
'RAIL_EXPIRATION': result.get('exp'),
|
self.session.cookies.update({
|
||||||
'RAIL_DEVICEID': result.get('dfp'),
|
'RAIL_EXPIRATION': result.get('exp'),
|
||||||
})
|
'RAIL_DEVICEID': result.get('dfp'),
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
self.session.cookies.update({
|
||||||
|
'RAIL_EXPIRATION': Config().RAIL_EXPIRATION,
|
||||||
|
'RAIL_DEVICEID': Config().RAIL_DEVICEID,
|
||||||
|
})
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user