自动切换ip说明

pull/230/head^2
wenxianping 2019-01-23 12:28:41 +08:00
parent ed4e4dc688
commit e2c645f7f7
4 changed files with 9 additions and 8 deletions

View File

@ -5,9 +5,9 @@
- 依赖库
- 依赖若快 若快注册地址http://www.ruokuai.com/client/index?6726 推荐用若快,打码兔平台已经关闭
- 项目依赖包 requirements.txt
- 安装方法-Windows: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
- 安装方法-Windows:
- 安装方法-Linux:
- root用户(避免多python环境产生问题): python2 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
- root用户(避免多python环境产生问题): python2 -m pip install -i https://pypi.tuna.tsinghua.e pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txtdu.cn/simple -r requirements.txt
- 非root用户避免安装和运行时使用了不同环境: sudo python2 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
- 项目使用说明

View File

@ -11,7 +11,6 @@ import wrapcache
from agency.cdn_utils import CDNProxy
from config import urlConf, configCommon
from config.AutoSynchroTime import autoSynchroTime
from config.TicketEnmu import ticket
from config.configCommon import seat_conf
from config.configCommon import seat_conf_2
@ -213,7 +212,8 @@ class select:
from_station, to_station = self.station_table(self.from_station, self.to_station)
num = 0
s = getPassengerDTOs(session=self, ticket_peoples=self.ticke_peoples)
s.sendGetPassengerDTOs()
passenger = s.sendGetPassengerDTOs()
wrapcache.set("user_info", passenger, timeout=9999999)
while 1:
try:
num += 1

View File

@ -17,7 +17,7 @@ def getPassCodeNewOrderAndLogin(session, imgType):
else:
codeImgUrl = copy.deepcopy(session.urls["codeImgByOrder"])
codeImgUrl["req_url"] = codeImgUrl["req_url"].format(random.random())
print (u"下载验证码...")
print(u"下载验证码...")
img_path = './tkcode.png'
result = session.httpClint.send(codeImgUrl)
try:
@ -34,4 +34,4 @@ def getPassCodeNewOrderAndLogin(session, imgType):
img.write(result)
return result
except OSError:
print (u"验证码下载失败可能ip被封确认请手动请求: {0}".format(codeImgUrl))
print(u"验证码下载失败可能ip被封确认请手动请求: {0}".format(codeImgUrl))

View File

@ -130,6 +130,7 @@ class HTTPClient(object):
url_host = urls["Host"]
else:
url_host = urls["Host"]
http = urls.get("httpType") or "https"
for i in range(re_try):
try:
# sleep(urls["s_time"]) if "s_time" in urls else sleep(0.001)
@ -141,7 +142,7 @@ class HTTPClient(object):
response = self._s.request(method=method,
timeout=2,
proxies=self._proxies,
url="https://" + url_host + req_url,
url=http + "://" + url_host + req_url,
data=data,
allow_redirects=allow_redirects,
verify=False,
@ -160,7 +161,7 @@ class HTTPClient(object):
else:
logger.log(
u"url: {} 返回参数为空".format(urls["req_url"]))
return error_data
continue
else:
sleep(urls["re_time"])
except (requests.exceptions.Timeout, requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError):