如下:
# highest/lowest proxy scores that /random api should get.
# default /random api get the max score proxy(if exists) or all proxies in pool
PROXY_SCORE_RAND_MAX = env.int('PROXY_SCORE_RAND_MAX', PROXY_SCORE_MAX)
PROXY_SCORE_RAND_MIN = env.int('PROXY_SCORE_RAND_MIN', PROXY_SCORE_MIN)
# whether to decrease the score even when one proxy is tested valid
# use this param combined with proper PROXY_SCORE_XX params, can let you allways get the newest proxy with /random api
TEST_ALLWAYS_DECREASE_SCORE = env.bool('TEST_ALLWAYS_DECREASE_SCORE', False)
典型需求:需要从代理池中取到最新入池的一部分proxy ip.
此时可以在运行时设置环境变量:
export PROXY_SCORE_MAX=15
export PROXY_SCORE_MIN=0
# /random will get proxy with score of PROXY_SCORE_RAND_MAX ~ PROXY_SCORE_MAX, which is 13~15
export PROXY_SCORE_RAND_MAX=13
# if not exists, try to get proxy with score of PROXY_SCORE_RAND_MIN ~ PROXY_SCORE_MAX, which is 5~15
export PROXY_SCORE_RAND_MIN=5
# decrease the score each test cycle, even when one proxy is tested valid, to trace of 'lifetime' with score of proxy ip
export TEST_ALLWAYS_DECREASE_SCORE=True
如下:
典型需求:需要从代理池中取到最新入池的一部分proxy ip.
此时可以在运行时设置环境变量: