Skip to content

Commit d69d751

Browse files
committed
first version
1 parent bc819fa commit d69d751

10 files changed

Lines changed: 1349 additions & 0 deletions

File tree

Gopkg.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
[metadata]
7+
license = "Apache 2.0"
8+
owners_name = "SpringDRen"
9+
10+
required = ["github.com/SpringDRen/easylog","gopkg.in/ini.v1"]
11+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project"
15+
# version = "1.0.0"
16+
#
17+
# [[constraint]]
18+
# name = "github.com/user/project2"
19+
# branch = "dev"
20+
# source = "github.com/myfork/project2"
21+
#
22+
# [[override]]
23+
# name = "github.com/x/y"
24+
# version = "2.4.0"
25+
26+
27+
[[constraint]]
28+
version = "=1.0.0"
29+
name = "github.com/SpringDRen/easylog"
30+
31+
[[constraint]]
32+
name = "gopkg.in/ini.v1"
33+
version = "=1.28.2"

conf/12306.ini

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[leftTicket]
2+
#12306售票时间;非本时间可查询,但是无法购票
3+
time = 06:00-23:00
4+
#票务信息查询网址
5+
url = https://kyfw.12306.cn/otn/leftTicket/queryX?leftTicketDTO.train_date=${day}&leftTicketDTO.from_station=${from}&leftTicketDTO.to_station=${to}&purpose_codes=ADULT
6+
7+
#防止查询被禁,添加头部信息
8+
[Header]
9+
Connection = keep-alive
10+
Cache-Control = no-cache
11+
Pragma = no-cache
12+
If-Modified-Since = 0
13+
Host = kyfw.12306.cn
14+
Referer = https://kyfw.12306.cn/otn/leftTicket/init
15+
User-Agent = Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
16+
# 查询持续失败,请自行更改Cookie
17+
Cookie = tk=7eLwS4i_WNbItxSk1jIBDdsP4kMRfrZbL86eTA36r1r0; JSESSIONID=99224930E474771B256924D3034982C1; _jc_save_detail=true; RAIL_OkLJUJ=FDaP0EUw8e3W6KCRz0KWiVtdP53XXyge; fp_ver=4.5.1; RAIL_EXPIRATION=1506334557518; RAIL_DEVICEID=IVZetN6RYSOnKrPZnmeboNvq5ahDMCpfd-_oBCwDZIyME9377b5SITHUAGpUnmc9JB5UUj5sghFZuvoHklGuaOqOEZTzIdm38dKge02Y1lyy2_cNi9XEjDpibOn4-T8d3MWi_e9xDG0mxxdD_-lz9hb7Coe6XTud; BIGipServerpool_passport=250413578.50215.0000; BIGipServerpassport=887619850.50215.0000; current_captcha_type=Z; route=495c805987d0f5c8c84b14f60212447d; BIGipServerotn=1206911498.64545.0000; _jc_save_fromStation=%u5317%u4EAC%2CVNP; _jc_save_toStation=%u6D4E%u5357%2CJGK; _jc_save_fromDate=2017-09-29; _jc_save_toDate=2017-09-26; _jc_save_wfdc_flag=dc
18+
19+
[station]
20+
#是否更新本地station_name文件
21+
updateStation = false
22+
#12306 station_name url
23+
url = https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9026

conf/conf.ini

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[leftTicket]
2+
# 多个查询需要配置多个[section],名称不能相同,多个用英文,隔开
3+
all = first,second
4+
# 查询周期,整数,单位分钟
5+
period = 2
6+
7+
[first]
8+
#乘车日期,必须,yyyy-MM-dd e.g. 2017-09-30
9+
day = 2017-09-29
10+
#乘车站,必须 e.g. 北京
11+
from = 北京
12+
#抵达站,必须 e,g, 济南
13+
to = 济南
14+
# 开始时间 HH:mm, e.g.06:00;为空匹配所有
15+
starttime = 06:00
16+
# 截止时间 HH:mm, e.g. 12:00;为空匹配所有
17+
endtime = 12:00
18+
# 车次类型,大写英文字母,多个用英文,隔开;为空匹配所有,G-高铁 C-城际 D-动车 Z-直达 T-特快 K-快速 QT-其他
19+
train_type = G
20+
# 车次,多个用英文,隔开;为空匹配所有
21+
train =
22+
# 座位,汉字,多个用英文,隔开;为空匹配所有;商务座,特等座,一等座,二等座,高级软卧,软卧,硬卧,动卧,软座,硬座,无座,其他
23+
prior_seat = 一等座,二等座
24+
25+
[second]
26+
day = 2017-09-30
27+
from = 北京
28+
to = 济南
29+
starttime = 06:00
30+
endtime = 12:00
31+
train_type = G
32+
prior_seat = 一等座,二等座
33+
34+
#smtp 协议发送邮件
35+
[smtpmail]
36+
#是否开启发送邮件
37+
mailflag = false
38+
#地址:端口
39+
address = smtp.163.com:25
40+
#发送方邮箱地址
41+
username =
42+
#发送方邮箱密码
43+
password =
44+
#接收方,只支持单个
45+
to =
46+
#邮件主题
47+
subject = "余票查询"
48+
49+
#使用企业微信
50+
[qyweixin]
51+
#是否开启微信
52+
weixinflag = false
53+
#企业微信号
54+
corpid =
55+
#应用 secret
56+
corpsecret =
57+
#应用 id
58+
agentid =
59+
#微信用户名,多个用|隔开
60+
touser =
61+
62+
[logger]
63+
#ALL = console + file;FILE = 仅文件
64+
output = ALL
65+
dir = ./
66+
name = leftTicket.log
67+
#DEBUG/INFO/ERROR
68+
level = INFO
69+
70+
71+
72+
73+

lefttk/cfg.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package lefttk
2+
3+
import (
4+
"github.com/SpringDRen/easylog"
5+
"gopkg.in/ini.v1"
6+
)
7+
8+
//读取ini文件中的某个section,返回map键值对,忽略行内注释
9+
func GetSectionCfg(file string, sectionName string) map[string]string {
10+
result := make(map[string]string)
11+
//忽略行内注释
12+
cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, file)
13+
if err != nil {
14+
easylog.Error("can't load cfg", file, err)
15+
return nil
16+
}
17+
section, err := cfg.GetSection(sectionName)
18+
if err != nil {
19+
easylog.Error("can't read section", sectionName, err)
20+
return nil
21+
}
22+
for _, k := range section.Keys() {
23+
result[k.Name()] = k.String()
24+
}
25+
return result
26+
}

0 commit comments

Comments
 (0)