mirror of https://github.com/testerSunshine/12306
docker启动
parent
650f0106e3
commit
ce0b5cff84
|
@ -13,8 +13,13 @@
|
|||
- 配置yaml文件的时候,需注意空格和遵循yaml语法格式
|
||||
|
||||
- 项目开始
|
||||
- 服务器启动:
|
||||
- 修改config/ticket_config.yaml文件,按照提示更改自己想要的信息
|
||||
- 运行根目录run.py,即可开始
|
||||
- 如果你的服务器安装了docker,那么就可以docker启动
|
||||
- 1、docker build -t dockerautosign .
|
||||
- 2、docker run dockerautosign python start.py &
|
||||
- 3、本来是可以直接Dockerfile启动的,不知道为毛启动不了,如果有大佬看到问题所在,欢迎提出
|
||||
|
||||
- 目录对应说明
|
||||
- agency - cdn代理
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#encoding=utf8
|
||||
import socket
|
||||
import time
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
@ -19,6 +21,7 @@ class proxy:
|
|||
header['User-Agent'] = User_Agent
|
||||
|
||||
for i in range(1, 5):
|
||||
time.sleep(1)
|
||||
url = 'http://www.xicidaili.com/nn/'+str(i)
|
||||
res = requests.get(url=url, headers=header).content
|
||||
|
||||
|
@ -29,6 +32,7 @@ class proxy:
|
|||
ip = ips[x]
|
||||
tds = ip.findAll("td")
|
||||
ip_temp = tds[1].contents[0] + ":" + tds[2].contents[0]
|
||||
print(ip_temp)
|
||||
self.proxy_list.append(ip_temp)
|
||||
|
||||
def filter_proxy(self):
|
||||
|
@ -38,18 +42,21 @@ class proxy:
|
|||
"""
|
||||
socket.setdefaulttimeout(1)
|
||||
f = open("./proxy_list", "w")
|
||||
url = "http://ip.chinaz.com/getip.aspx"
|
||||
head = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
|
||||
'Connection': 'keep-alive'}
|
||||
url = "http://icanhazip.com"
|
||||
proxy_num = 0
|
||||
for proxy in self.proxy_list:
|
||||
proxy_temp = {"http://": proxy}
|
||||
proxy_temp = {"https": "https://{}".format(proxy)}
|
||||
try:
|
||||
req = requests.get(url, proxies=proxy_temp).content
|
||||
req = requests.get(url, proxies=proxy_temp, timeout=2, headers=head).content
|
||||
print(req)
|
||||
write_proxy = proxy+"\n"
|
||||
f.write(write_proxy)
|
||||
proxy_num += 1
|
||||
except Exception, e:
|
||||
print ("代理链接超时,去除此IP:{0}".format(proxy))
|
||||
print e
|
||||
continue
|
||||
print("总共可使用ip量为{}个".format(proxy_num))
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ def sendEmail(msg):
|
|||
email_conf = _get_yaml()
|
||||
is_email = email_conf["email_conf"]["is_email"]
|
||||
if is_email:
|
||||
try:
|
||||
sender = email_conf["email_conf"]["email"]
|
||||
receiver = email_conf["email_conf"]["notice_email_list"]
|
||||
subject = '恭喜,您已订票成功'
|
||||
|
@ -33,7 +34,9 @@ def sendEmail(msg):
|
|||
smtp.login(username, password)
|
||||
smtp.sendmail(sender, receiver.split(","), msg.as_string())
|
||||
smtp.quit()
|
||||
print("邮件已通知, 请查收")
|
||||
print(u"邮件已通知, 请查收")
|
||||
except Exception as e:
|
||||
print(u"邮件配置有误", e)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ set:
|
|||
# - 2018-01-06
|
||||
# - 2018-01-07
|
||||
station_dates:
|
||||
- "2018-09-28"
|
||||
- "2018-12-29"
|
||||
|
||||
# 是否根据时间范围 和 乘车类型 购票
|
||||
# 否则将需要手动填写车次
|
||||
|
@ -30,47 +30,61 @@ set:
|
|||
# - "G1353"
|
||||
# - "G1329"
|
||||
station_trains:
|
||||
- ""
|
||||
|
||||
# - "G6114"
|
||||
# - "G1311"
|
||||
# - "G6201"
|
||||
# - "G821"
|
||||
# - "G1019"
|
||||
# - "G6587"
|
||||
# - "G2905"
|
||||
# - "G6345"
|
||||
# - "G6033"
|
||||
# - "G75"
|
||||
# - "G6025"
|
||||
# - "G6341"
|
||||
# - "G1021"
|
||||
# - "G99"
|
||||
- "G6011"
|
||||
|
||||
# 出发城市,比如深圳北,就填深圳就搜得到
|
||||
from_station: ""
|
||||
from_station: "长沙"
|
||||
|
||||
# 到达城市 比如深圳北,就填深圳就搜得到
|
||||
to_station: ""
|
||||
to_station: "深圳"
|
||||
|
||||
# 座位(list) 多个座位ex:
|
||||
# - "二等座"
|
||||
# - "一等座"
|
||||
set_type:
|
||||
- ""
|
||||
- "二等座"
|
||||
|
||||
# 当余票小于乘车人,如果选择优先提交,则删减联系人和余票数一致在提交
|
||||
is_more_ticket: False
|
||||
is_more_ticket: True
|
||||
|
||||
# 乘车人(list) 多个乘车人ex:
|
||||
# - "张三"
|
||||
# - "李四"
|
||||
ticke_peoples:
|
||||
- ""
|
||||
- "文贤平"
|
||||
- "梁敏"
|
||||
# 12306登录账号(list)
|
||||
12306account:
|
||||
- user: ""
|
||||
- pwd: ""
|
||||
- user: "931128603@qq.com"
|
||||
- pwd: "QWERTY"
|
||||
|
||||
# 加入小黑屋时间,此功能为了防止僵尸票导致一直下单不成功错过正常的票
|
||||
ticket_black_list_time: 5
|
||||
|
||||
# 自动打码
|
||||
is_auto_code: False
|
||||
is_auto_code: True
|
||||
|
||||
# 打码平台, 2 为若快平台(目前只支持若快平台打码,打码兔已经关闭), 若快注册地址:http://www.ruokuai.com/client/index?6726
|
||||
auto_code_type: 2
|
||||
|
||||
# 打码平台账号
|
||||
auto_code_account:
|
||||
user: ""
|
||||
pwd: ""
|
||||
user: "931128603"
|
||||
pwd: "wen1995"
|
||||
|
||||
# 邮箱配置,如果抢票成功,将通过邮件配置通知给您
|
||||
# 列举163
|
||||
|
@ -87,17 +101,17 @@ auto_code_account:
|
|||
# host: "smtp.qq.com"
|
||||
email_conf:
|
||||
is_email: True
|
||||
email: ""
|
||||
notice_email_list: ""
|
||||
username: ""
|
||||
password: ""
|
||||
host: ""
|
||||
email: "931128603@qq.com "
|
||||
notice_email_list: "931128603@qq.com"
|
||||
username: "931128603"
|
||||
password: "xrvenridfpnnbehh"
|
||||
host: "smtp.qq.com"
|
||||
|
||||
# 是否开启cdn查询,可以更快的检测票票 1为开启,2为关闭
|
||||
is_cdn: 2
|
||||
|
||||
# 下单接口分为两种,1 为快速下单,2 是普通下单
|
||||
order_type: 2
|
||||
order_type: 1
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ urls = {
|
|||
"is_json": True,
|
||||
},
|
||||
"select_url": { # 查询余票
|
||||
"req_url": "/otn/leftTicket/queryO?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT",
|
||||
"req_url": "/otn/leftTicket/queryX?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT",
|
||||
"req_type": "get",
|
||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
||||
"Host": "kyfw.12306.cn",
|
||||
|
@ -275,7 +275,7 @@ urls = {
|
|||
"re_time": 0.1,
|
||||
"s_time": 0.1,
|
||||
"is_logger": False,
|
||||
"is_json": True,
|
||||
"is_json": False,
|
||||
},
|
||||
"cancelNoCompleteMyOrder": { # 取消订单
|
||||
"req_url": "/otn/queryOrder/cancelNoCompleteMyOrder",
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
# coding=utf-8
|
||||
import copy
|
||||
import datetime
|
||||
import random
|
||||
|
||||
import wrapcache
|
||||
|
||||
from config import urlConf
|
||||
from config.TicketEnmu import ticket
|
||||
from myUrllib.httpUtils import HTTPClient
|
||||
from config.configCommon import seat_conf_2
|
||||
from utils.timeUtil import time_to_minutes
|
||||
|
||||
|
||||
class query:
|
||||
"""
|
||||
查询接口
|
||||
"""
|
||||
|
||||
def __init__(self, session, from_station, to_station, from_station_h, to_station_h, _station_seat, station_trains,
|
||||
ticke_peoples_num, station_dates=None,):
|
||||
ticke_peoples_num, station_dates=None, ):
|
||||
self.session = session
|
||||
self.httpClint = HTTPClient()
|
||||
self.urls = urlConf.urls
|
||||
|
@ -31,7 +28,7 @@ class query:
|
|||
self.ticket_black_list = dict()
|
||||
self.ticke_peoples_num = ticke_peoples_num
|
||||
|
||||
#by time
|
||||
# by time
|
||||
self.is_by_time = session.is_by_time
|
||||
self.train_types = session.train_types
|
||||
self.departure_time = session.departure_time
|
||||
|
@ -55,20 +52,20 @@ class query:
|
|||
}
|
||||
return seat[index]
|
||||
|
||||
def check_time_interval(self,ticket_info):
|
||||
def check_time_interval(self, ticket_info):
|
||||
return self.departure_time <= time_to_minutes(ticket_info[8]) and \
|
||||
time_to_minutes(ticket_info[9]) <= self.arrival_time and \
|
||||
time_to_minutes(ticket_info[10]) <= self.take_time
|
||||
|
||||
def check_train_types(self,train):
|
||||
def check_train_types(self, train):
|
||||
train_type = train[0]
|
||||
if train_type!="G" and train_type!="D":train_type="O"
|
||||
if train_type != "G" and train_type != "D": train_type = "O"
|
||||
if train_type in self.train_types:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def check_is_need_train(self,ticket_info):
|
||||
def check_is_need_train(self, ticket_info):
|
||||
if self.is_by_time:
|
||||
return self.check_train_types(ticket_info[3]) and self.check_time_interval(ticket_info)
|
||||
else:
|
||||
|
@ -94,7 +91,8 @@ class query:
|
|||
if ticket_info[11] == "Y" and ticket_info[1].encode("utf8") == "预订": # 筛选未在开始时间内的车次
|
||||
for j in self._station_seat:
|
||||
is_ticket_pass = ticket_info[j]
|
||||
if is_ticket_pass != '' and is_ticket_pass != '无' and is_ticket_pass != '*' and self.check_is_need_train(ticket_info): # 过滤有效目标车次
|
||||
if is_ticket_pass != '' and is_ticket_pass != '无' and is_ticket_pass != '*' and self.check_is_need_train(
|
||||
ticket_info): # 过滤有效目标车次
|
||||
secretStr = ticket_info[0]
|
||||
train_no = ticket_info[2]
|
||||
query_from_station_name = ticket_info[6]
|
||||
|
@ -102,10 +100,10 @@ class query:
|
|||
train_location = ticket_info[15]
|
||||
stationTrainCode = ticket_info[3]
|
||||
leftTicket = ticket_info[12]
|
||||
start_time=ticket_info[8]
|
||||
arrival_time=ticket_info[9]
|
||||
distance_time=ticket_info[10]
|
||||
print start_time,arrival_time,distance_time
|
||||
start_time = ticket_info[8]
|
||||
arrival_time = ticket_info[9]
|
||||
distance_time = ticket_info[10]
|
||||
print start_time, arrival_time, distance_time
|
||||
seat = j
|
||||
try:
|
||||
ticket_num = int(ticket_info[j])
|
||||
|
@ -122,7 +120,8 @@ class query:
|
|||
else:
|
||||
if ticket_num != "有" and self.ticke_peoples_num > ticket_num:
|
||||
if self.session.is_more_ticket:
|
||||
print(u"余票数小于乘车人数,当前余票数: {}, 删减人车人数到: {}".format(ticket_num, ticket_num))
|
||||
print(
|
||||
u"余票数小于乘车人数,当前余票数: {}, 删减人车人数到: {}".format(ticket_num, ticket_num))
|
||||
is_more_ticket_num = ticket_num
|
||||
else:
|
||||
print(u"余票数小于乘车人数,当前设置不提交,放弃此次提交机会")
|
||||
|
|
|
@ -75,8 +75,7 @@ class queryOrderWaitTime:
|
|||
queryMyOrderNoCompleteResult = {}
|
||||
if queryMyOrderNoCompleteResult:
|
||||
if queryMyOrderNoCompleteResult.get("data", False) and queryMyOrderNoCompleteResult["data"].get("orderDBList", False):
|
||||
orderId = queryMyOrderNoCompleteResult["data"]["orderDBList"][0]["sequence_no"]
|
||||
return orderId
|
||||
return queryMyOrderNoCompleteResult["data"]
|
||||
elif queryMyOrderNoCompleteResult.get("data", False) and queryMyOrderNoCompleteResult["data"].get("orderCacheDTO", False):
|
||||
if queryMyOrderNoCompleteResult["data"]["orderCacheDTO"].get("message", False):
|
||||
print(queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]["message"])
|
||||
|
@ -96,7 +95,6 @@ class queryOrderWaitTime:
|
|||
获取订单前需要进入订单列表页,获取订单列表页session
|
||||
:return:
|
||||
"""
|
||||
self.session.httpClint.set_cookies(acw_tc="AQAAAEnFJnekLwwAtGHjZZCr79B6dpXk", current_captcha_type="Z")
|
||||
initNoCompleteUrl = self.session.urls["initNoCompleteUrl"]
|
||||
data = {"_json_att": ""}
|
||||
self.session.httpClint.send(initNoCompleteUrl, data)
|
||||
|
|
Loading…
Reference in New Issue